Class StyleSheet
- Namespace
- SheetStream.Styles
- Assembly
- SheetStream.dll
The workbook's style registry. Translates StyleOptions into the five interlocking tables SpreadsheetML needs (number formats, fonts, fills, borders and cell formats), de-duplicating each so a workbook with a thousand "bold blue header" cells carries a single font record.
public sealed class StyleSheet
- Inheritance
-
StyleSheet
- Inherited Members
Remarks
Styles can be created at any time before the package is saved; the styles.xml part is
written last, after every sheet has been streamed. Not thread-safe.
Properties
Count
Number of registered cell styles, including the default (and the template's, when filling one).
public int Count { get; }
Property Value
Default
The workbook default style (Calibri 11, no fill, no border, General format).
public CellStyle Default { get; }
Property Value
Hyperlink
Excel's built-in "Hyperlink" cell style (blue, underlined). Hyperlink cells use it unless given another style, so they look and behave like links typed in Excel.
public CellStyle Hyperlink { get; }
Property Value
Methods
Create(StyleOptions)
Creates (or reuses) a style from a fully populated StyleOptions.
public CellStyle Create(StyleOptions options)
Parameters
optionsStyleOptions
Returns
Create(Action<StyleOptions>)
Creates (or reuses) a style from a configuration callback.
public CellStyle Create(Action<StyleOptions> configure)
Parameters
configureAction<StyleOptions>
Returns
Examples
var header = workbook.Styles.Create(o =>
{
o.Font.Bold = true;
o.Font.Color = "#FFFFFF";
o.Fill.BackgroundColor = "#4F81BD";
});
CreateDifferential(Action<StyleOptions>)
Creates (or reuses) a differential format for conditional formatting. Only the font colour, bold / italic / underline / strikethrough, fill colour, borders and number format are used; font name and size are ignored because Excel does not apply them conditionally.
public DifferentialStyle CreateDifferential(Action<StyleOptions> configure)
Parameters
configureAction<StyleOptions>
Returns
Examples
var bad = workbook.Styles.CreateDifferential(o => { o.Font.Color = "#9C0006"; o.Fill.BackgroundColor = "#FFC7CE"; });