xlsgen > overview > Formatting

Formatting takes care of all cell properties, and are found in Excel by right-clicking on a cell and choosing Format Cell, or with toolbar shortcuts. Examples of formatting properties are : background color, font style, border color, text alignment, ...


The formatting properties can be broken down into the following sections :

Styles are also part of rich labels and conditional formatting. See IXlsRichLabel and IXlsConditionalFormatting for more information.

All those properties are style properties, and are part of a style object. See IXlsStyle for more information.

Users can create as much styles as they want. Styles are created from the current worksheet (see IXlsWorksheet for more information), or by duplicating an existing style. Duplicated styles can be further customized.

Once properties for a given style are set, they must be provided to the generation engine by calling the Apply() method. A style applies to all cells created afterwards, whether simple cells or merged cells.

A sample code that creates and sets a style is as follows :

VB code

' create a new style
Dim style As IXlsStyle
Set style = wksht.NewStyle

style.Format = "###,###.00 F"
style.Apply

' cells now use this style
wksht.Float(3, 2) = 5 ' put 5.00 in row 3, column 2

' duplicate the current style
Dim style2 As IXlsStyle
Set style2 = style.Duplicate

' and further customize it
style2.Format = "[Yellow]### ###.0"
style2.Apply

' cells now use this style
wksht.Float(4, 2) = 5 ' put 5.00 in row 4, column 2


C# code

// create a new style
IXlsStyle style = wksht.NewStyle();

style.Format = "###,###.00 F";
style.Apply();

// cells now use this style
wksht.set_Float(3, 2, 5.00); // put 5.00 in row 3, column 2

// duplicate the current style
IXlsStyle style2 = style.Duplicate();

// and further customize it
style2.Format = "[Yellow]### ###.0";
style2.Apply();

// cells now use this style
wksht.set_Float(4, 2, 5.00); // put 5.00 in row 4, column 2

C/C++ code

// create a new style
xlsgen::IXlsStylePtr style = wksht->NewStyle();

style->Format = "###,###.00 F";
style->Apply();

// cells now use this style
wksht->Float[3][2] = 5.00; // put 5.00 in row 3, column 2

// duplicate the current style
xlsgen::IXlsStylePtr style2 = style->Duplicate();

// and further customize it
style2->Format = "[Yellow]### ###.0";
style2->Apply();

// cells now use this style
wksht->Float[4][2] = 5.00; ' put 5.00 in row 4, column 2

 

xlsgen documentation. © ARsT Design all rights reserved.