Xceed Grid for WinForms v4.3 Documentation
Welcome to Xceed Grid for WinForms v4.3 / Basic Concepts / Exporting spreadsheets to Excel / ExcelStyle class

In This Topic
    ExcelStyle class
    In This Topic

    The ExcelStyle class is used to apply styles to the column header of a spreadsheet through the ColumnHeaderStyle property.

    The ExcelStyle class

    The ExcelStyle class contains five properties that control the style. The BackColor and ForeColor properties control the background and foreground color, respectively. The ContentAlignment property contains a System.Drawing.ContentAlignment value that determines how the cell content will be aligned. The Font property determines the font to be used. Finally, the ID property holds a string representing the name of the ExcelStyle. 

    An ExcelStyle object can be created either by passing the desired characteristics to one version of its constructor, or by passing a GridElement, whose appearance will be applied to the ExcelStyle object's properties. 

    For example, the following code creates an ExcelStyle object with a red background, white foreground (the lettering), 9-point Microsoft Sans Serif, and with MiddleCenter alignment.

    VB.NET
    Copy Code
    Imports Xceed.Grid.Exporting
    Dim excelStyle As New ExcelStyle(Color.Red, _
                                     Color.White,New System.Drawing.Font("Microsoft Sans Serif", _
                                     9, FontStyle.Bold),ContentAlignment.MiddleCenter)
    C#
    Copy Code
    using Xceed.Grid.Exporting;
    ExcelStyle excelStyle1 = new ExcelStyle(Color.Red, Color.White,
                                            new System.Drawing.Font("Microsoft Sans Serif", 9,
                                            fontStyle.Bold), ContentAlignment.MiddleCenter);

    The following snippet uses gridElement1 as a "template" for the ExcelStyle object:

    VB.NET Copy Code
    Imports Xceed.Grid.Exporting

    Dim excelStyle As New ExcelStyle( gridElement1 )
    C# Copy Code
    using Xceed.Grid.Exporting;

    ExcelStyle excelStyle = new ExcelStyle( gridElement1 );