Message-ID: <770066263.7715.1711619000014.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_7714_656416586.1711619000014" ------=_Part_7714_656416586.1711619000014 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
ExcelWriter creates three style types: GlobalStyle, NamedStyle, an=
d CellStyle. All three style types d=
erive from the Style class, and Na=
medStyle
derives from GlobalStyle
.
public sealed class NamedStyle : GlobalStyle=20
Public NotInheritable Class NamedStyle =09=09Inherits GlobalStyle=20
A style can be set or= applied to cells, rows,= columns, ranges, and areas. When a style is set , it is cloned and the object to which the style i= s assigned acquires all of that style's properties, including font proprtie= s and number formatting. When a style is applied , only the differences between the new style and e= xisting style properties (assigned through the ExcelWriter API or in Micros= oft Excel) will take effect. For example, if the cell has a background colo= r and the new style applied does not contain a background color, the cell's= color will not be affected. However, if the new style includes a backgroun= d color, it will replace the existing background color of the cell.
=20The ExcelAppl=
ication object contains a collection of NamedStyle
s, whic=
h - unlike GlobalStyle
s are accessible after the workbook is =
saved. This allows you to dynamically create a template, save it to disk, r=
e-open it to populate it with data, and then apply your newly-created style=
. This collection of NamedStyle
s includes Excel's built-in st=
yles (such as the NORMAL style) and any user-defined styles in a workbook o=
pened with the ExcelApplication object.
To create a NamedStyle
, call Workbook.CreateNamedStyle.
To return a NamedStyle
, call Workbook.GetNamedStyle.
ExcelApplication xla =3D new ExcelApplication(); Workbook wb =3D xla.Create(); //--- Create a named style. Style myItalicStyle =3D wb.CreateNamedStyle("ItalicStyle&quo= t;); //--- Turn on italics for the named style. myGlobalStyle.Font.Italics =3D true; //--- Get a "total" cell Cell totalCell =3D wb.Worksheets[0].Cells[4, 4]; //--- Check its value and apply style if necessary if(totalCell.Value > TARGET_TOTAL_VALUE) totalCell.ApplyStyle(myItalicStyle);=20
Dim xla As New ExcelApplication() Workbook wb =3D xla.Create() '--- Create a named style. Dim myItalicStyle As Style =3D wb.CreateNamedStyle("ItalicSt= yle") '--- Turn on italics for the named style myGlobalStyle.Font.Italics =3D True '--- Get a "total" cell Dim totalCall As Cell =3D wb.Worksheets(0).Cells(4, 4) '--- Check its value and apply style if necessary If totalCell.Value > TARGET_TOTAL_VALUE Then totalCell.ApplyStyle(myItalicStyle) End If=20
Name | =20
Description | =20
---|---|
=20 | Returns the style's name. This can be used to ac= cess the style later, and will appear in the Styles dialog in Excel. | = =20