Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Description

Excerpt

ExcelWriter creates three style types: GlobalStyle, NamedStyle, and CellStyle. All three style types derive from the Style class, and NamedStyle derives from GlobalStyle.

Signature
C#
C#

<p> public class GlobalStyle : Style
{signature}{signature:Style</p>
} Public
Signature
vb.net
vb.net

<p>Public Class GlobalStyleGlobalStyle<br />
		Inherits Style
{signature}
{remarks}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 is assigned acquires all of that style's properties, including font properties and number formatting. When a style is +applied+, only the differences between the new style and existing style properties \(assigned through the ExcelWriter API or in Microsoft Excel\) will take effect. For example, if the cell has a background color 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 background color, it will replace the existing background color of the cell.

To +set+ a style, use the {{Style}} property. To +apply+ a style, call {{ApplyStyle}}. Both are accessible through the following objects: [Cell|Cell], [Area|Area], [Range|Range], [RowProperties|RowProperties], and [ColumnProperties|ColumnProperties].

{remarks}
{example}{code:csharp|title=C#}Style</p>
Remarks

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 is assigned acquires all of that style's properties, including font properties and number formatting. When a style is applied, only the differences between the new style and existing style properties (assigned through the ExcelWriter API or in Microsoft Excel) will take effect. For example, if the cell has a background color 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 background color, it will replace the existing background color of the cell.

To set a style, use the Style property. To apply a style, call ApplyStyle. Both are accessible through the following objects: Cell, Area, Range, RowProperties, and ColumnProperties.

Example
Code Block
csharp
csharp
titleC#


          Style styleMoneyFormat = wb.CreateStyle();
          styleMoneyFormat.NumberFormat = "$#,##0";
          Style styleTitle = wb.CreateStyle();
          styleTitle.Font.Size = 14;
          styleTitle.Font.Color = wb.Palette.GetClosestColor(100, 100, 255);
        
{code} {code:vbnet|title=
Code Block
vbnet
vbnet
titlevb.net
}


          Dim styleMoneyFormat As Style = wb.CreateStyle()
          styleMoneyFormat.NumberFormat = "$#,##0"
          Dim styleTitle As Style = wb.CreateStyle()
          styleTitle.Font.Size = 14
          styleTitle.Font.Color = wb.Palette.GetClosestColor(100, 100, 255)
        
{code} {example}