[]
Represents a style that can be applied to a range.
An IStyle defines formatting such as font, borders, fill,
number format, alignment, and protection settings for cells. Styles are
typically created or retrieved through the workbook's IStyleCollection
and then applied to an IRange.
public interface IStyle
Public Interface IStyle
IStyle style = workbook.Styles.Add("Highlight");
style.Font.Bold = true;
style.HorizontalAlignment = HorizontalAlignment.Center;
worksheet.Range["A1"].Style = style;
| Name | Description |
|---|---|
| AddIndent | Gets or sets whether text is automatically indented when the text alignment in a cell is set to equal distribution either horizontally or vertically. Use this property to control or inspect the automatic indent setting used for distributed text alignment. |
| Borders | Gets the IBorders collection that represents the borders of a style. Use this property to access and modify the border settings stored in the style. |
| BuiltIn | Gets whether the style is a built-in style. Use this property to determine whether a style comes from the built-in workbook styles rather than a custom named style. |
| Font | Gets the IFont object that represents this style's font. Use this property to access font settings such as bold, size, color, and font name for the style. |
| FormulaHidden | Gets or sets whether the formula is hidden when the worksheet is protected. Use this property to control whether cells that use the style hide their formulas after worksheet protection is enabled. |
| HorizontalAlignment | Gets or sets the horizontal alignment for this style. Use this property to define or retrieve how content is aligned horizontally when the style is applied. |
| IncludeAlignment | Gets or sets whether style includes the IStyle.AddIndent, IStyle.HorizontalAlignment, IStyle.VerticalAlignment, IStyle.WrapText, and IStyle.Orientation properties. Use this property to control or inspect whether alignment-related settings participate when the style is applied. |
| IncludeBorder | Gets or sets whether the style includes the IBorder.Color, IBorder.ColorIndex,IBorder.LineStyle, and IBorder.Weight border properties. Use this property to control or inspect whether border settings defined on the style are included when the style is applied. |
| IncludeFont | Gets or sets whether the style includes the IFont.Bold, IFont.Color,IFont.ColorIndex, IFont.FontStyle,IFont.Italic, IFont.Name,IFont.OutlineFont, IFont.Shadow,IFont.Size, IFont.Strikethrough,IFont.Subscript, IFont.Superscript, and IFont.Underline font properties. Use this property to control or inspect whether font settings stored in the style are included when the style is applied. |
| IncludeNumber | Gets or sets whether the style includes the IStyle.NumberFormat property. Use this property to control or inspect whether the number format stored in the style is included when the style is applied. |
| IncludePatterns | Gets or sets whether the style includes the IInterior.Color, IInterior.InvertIfNegative, IInterior.Pattern, IInterior.PatternColor, and IInterior.PatternColorIndex interior properties. Use this property to control or inspect whether interior pattern settings are included when the style is applied. |
| IncludeProtection | Gets or sets whether the style includes the IStyle.FormulaHidden and IStyle.Locked properties. Use this property to control or inspect whether protection-related settings defined by the style participate when the style is applied. |
| IndentLevel | Gets or sets the indent level for the style. Use this property to define or retrieve the indentation applied to cell content when the style is assigned. |
| Interior | Gets the IInterior object that represents this style's fill formatting. Use this property to access fill and pattern settings such as background color and pattern style for the style. |
| Locked | Gets or sets whether the object is locked; False if the object can be modified when the sheet is protected. Use this property to control whether cells that use the style are locked when worksheet protection is enabled. |
| Name | Gets the name of the object. Use this property to get the name of the named style stored in the workbook. |
| NumberFormat | Gets or sets the format code for the object as a string in the language of the user. Use this property to define or retrieve the number format code stored in the style. |
| Orientation | Gets or sets the text orientation. Can be an integer value from –90 to 90 degrees. Use this property to define or retrieve the text rotation stored in the style. |
| ShrinkToFit | Gets or sets whether the text automatically shrinks to fit in the available column width. Use this property to control whether cells that use the style shrink text to fit the available column width. |
| VerticalAlignment | Gets or sets the vertical alignment for this style. Use this property to define or retrieve how content is aligned vertically when the style is applied. |
| WrapText | Gets or sets whether text wraps automatically. Use this property to control whether text in cells that use the style is wrapped. |
| Name | Description |
|---|---|
| Delete() | Deletes this style. Use this method to remove a custom named style from the workbook. Built-in styles cannot be deleted. |
| FromJson(string) | Generates the named style from the JSON string. Use this method to load a named style definition from JSON, such as a string previously generated by ToJson(). |
| ToJson() | Generates a JSON string from the named style. Use this method to serialize a named style to JSON so that it can be stored or used later with FromJson(string). |