xlsgen > overview > Alignment |
Alignment is the ability to control how the content gets positioned in the cell or merged cells. Alignment options are numerous and a couple of those have just been added in more recent Excel releases. xlsgen supports alignment options that apply to the entire range of Excel versions.
Alignment options are accessed by right-clicking on a cell and choosing Format Celland then clicking on the Alignment tab. The most common alignment options are also provided in the formatting toolbar.
Alignment options in xlsgen actually support the following :
Alignment options are properties of the current style object. See formatting for more information.
Alignment options are particularly beneficial with merged cells, since that's the only way to position the content within a bounding zone.
A sample code that plays with alignment options to produce the result above is :
VB code |
Dim style As IXlsStyle Set style = wksht.NewStyle style.Alignment.Horizontal = halign_left style.Apply wksht.Label(3, 2) = "hi!" ' put in row 3, column 2 Dim style2 As IXlsStyle Set style2 = style.Duplicate style2.Alignment.Horizontal = halign_center style2.Apply wksht.Label(4, 2) = "hi!" ' put in row 4, column 2 Dim style3 As IXlsStyle Set style3 = style.Duplicate style3.Alignment.Horizontal = halign_right style3.Apply wksht.Label(5, 2) = "hi!" ' put in row 5, column 2 |
C# code |
IXlsStyle style = wksht.NewStyle(); style.Alignment.Horizontal = xlsgen.enumHorizontalAlignment.halign_left; style.Apply(); wksht.set_Label(3,2, "hi!"); // put in row 3, column 2 IXlsStyle style2 = style.Duplicate(); style2.Alignment.Horizontal = xlsgen.enumHorizontalAlignment.halign_center; style2.Apply(); wksht.set_Label(4,2, "hi!"); // put in row 4, column 2 IXlsStyle style3 = style.Duplicate(); style3.Alignment.Horizontal = xlsgen.enumHorizontalAlignment.halign_right; style3.Apply(); wksht.set_Label(5,2, "hi!"); // put in row 5, column 2 |
C/C++ code |
xlsgen::IXlsStylePtr style = wksht->NewStyle(); style->Alignment->Horizontal = xlsgen::halign_left; style->Apply(); wksht->Label[3][2] = "hi!"; // put in row 3, column 2 xlsgen::IXlsStylePtr style2 = style->Duplicate(); style2->Alignment->Horizontal = xlsgen::halign_center; style2->Apply(); wksht->Label[4][2] = "hi!"; // put in row 4, column 2 xlsgen::IXlsStylePtr style3 = style->Duplicate(); style3->Alignment->Horizontal = xlsgen::halign_right; style3->Apply(); wksht->Label[5][2] = "hi!"; // put in row 5, column 2 |
xlsgen documentation. © ARsT Design all rights reserved.