Class Styles
Contains style information for a workbook. In general, you should not use this class directly. Instead, you should set properties on cells and ranges.
Inherited Members
Namespace: DRIT.Spreadsheet
Assembly: DRIT.Spreadsheet.dll
Syntax
public sealed class Styles
Constructors
Styles()
Initializes a new Styles for the supplied workbook data.
Declaration
public Styles()
Styles(Workbook)
Initializes a new Styles for the supplied workbook data.
Declaration
public Styles(Workbook workbook)
Parameters
| Type | Name | Description |
|---|---|---|
| Workbook | workbook |
Fields
DefaultFontStyleName
Exposes the string associated with Styles.
Declaration
public const string DefaultFontStyleName = "Cambria"
Field Value
| Type | Description |
|---|---|
| string | The string returned by the operation. |
Properties
IndexedColors
Exposes the indexed colors associated with Styles.
Declaration
public List<SpreadsheetColor> IndexedColors { get; }
Property Value
| Type | Description |
|---|---|
| List<SpreadsheetColor> | The indexed colors returned by the operation. |
this[BuiltInCellStyleType]
Gets the built-in cell style with the specified type, creating it if it does not already exist in the workbook's style sheet.
Declaration
public StyleSheetCellStyle this[BuiltInCellStyleType styleType] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| BuiltInCellStyleType | styleType | The built-in cell style type to retrieve. |
Property Value
| Type | Description |
|---|---|
| StyleSheetCellStyle | The StyleSheetCellStyle for the requested built-in style. |
Remarks
Excel UI: "Home > Cell Styles" gallery. If the style has not been previously added to the workbook, it is created and registered.
TableStyles
Exposes the table styles associated with Styles.
Declaration
public TableStyleCollection TableStyles { get; }
Property Value
| Type | Description |
|---|---|
| TableStyleCollection | The table styles returned by the operation. |
ThemeColors
Exposes the theme colors associated with Styles.
Declaration
public List<SpreadsheetColor> ThemeColors { get; }
Property Value
| Type | Description |
|---|---|
| List<SpreadsheetColor> | The theme colors returned by the operation. |
Methods
AddBuiltInStyle(StyleSheetCellStyle)
Adds the supplied built in style to the Styles.
Declaration
public void AddBuiltInStyle(StyleSheetCellStyle cellStyle)
Parameters
| Type | Name | Description |
|---|---|---|
| StyleSheetCellStyle | cellStyle | The cell style used by the operation. |
AddCustomStyle(CellStyle)
Adds the supplied custom style to the Styles.
Declaration
public void AddCustomStyle(CellStyle cellStyle)
Parameters
| Type | Name | Description |
|---|---|---|
| CellStyle | cellStyle | The cell style used by the operation. |
GetColorIndex(SpreadsheetColor, int)
Retrieves the requested color index from the Styles.
Declaration
public int GetColorIndex(SpreadsheetColor color, int nullValue)
Parameters
| Type | Name | Description |
|---|---|---|
| SpreadsheetColor | color | The color used by the operation. |
| int | nullValue | The null value used by the operation. |
Returns
| Type | Description |
|---|---|
| int | The get color index returned by the operation. |
GetCustomStyle(string)
Retrieves the requested custom style from the Styles.
Declaration
public StyleSheetCellStyle GetCustomStyle(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name used by the operation. |
Returns
| Type | Description |
|---|---|
| StyleSheetCellStyle | The get custom style returned by the operation. |
GetIndexedColorAsColor(int)
Returns the requested indexed Color As Color.
Declaration
public SpreadsheetColor GetIndexedColorAsColor(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index |
Returns
| Type | Description |
|---|---|
| SpreadsheetColor |
Remarks
IF the stylesheet contains indexed colors use those. If not get the color from the standard indexed colors palette.
GetStyle(string)
Retrieves the requested style from the Styles.
Declaration
public StyleSheetCellStyle GetStyle(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name used by the operation. |
Returns
| Type | Description |
|---|---|
| StyleSheetCellStyle | The get style returned by the operation. |