officefileapi-devexpress-dot-spreadsheet-5e9e730f.md
A named cell style.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
public interface Style :
Formatting
Public Interface Style
Inherits Formatting
The following members return Style objects:
The Style interface is inherited from the Formatting interface. You can use all properties of the parent class to perform direct cell formatting and create styles.
A style is a named set of predefined cell format characteristics. When applying a style, all format settings are applied to a cell or cell range in a single step. Cell styles are represented by the Style objects and contained within the StyleCollection collection accessible via the IWorkbook.Styles property. This collection includes a set of built-in styles (similar to Microsoft® Excel®) that can be obtained by the corresponding BuiltInStyleId enumeration members and custom styles that can be accessed by their names (Style.Name). Built-in cell styles (including the Normal style, which is applied to all unformatted cells) are contained in the collection by default, while custom styles can be added via the StyleCollection.Add method.
A style object provides a set of properties inherited from the Formatting interface that allow you to modify format attributes of the style. For details, see the How to: Create or Modify a Style example.
To apply a style to a cell or range of cells, use the CellRange.Style property (see the How to: Apply a Style to a Cell or Range of Cells example).
This example demonstrates how to format a cell, a range of cells, an entire row or an entire column by applying a style.
Style object that specifies the style to be applied to a cell or a range of cells. This style should be added to the IWorkbook.Styles collection.// Access the built-in "Good" MS Excel style from the Styles collection of the workbook.
Style styleGood = workbook.Styles[BuiltInStyleId.Good];
// Apply the "Good" style to a range of cells.
worksheet.Range["A1:C4"].Style = styleGood;
// Access a custom style that has been previously created in the loaded document by its name.
Style customStyle = workbook.Styles["Custom Style"];
// Apply the custom style to the cell.
worksheet.Cells["D6"].Style = customStyle;
// Apply the "Good" style to the eighth row.
worksheet.Rows[7].Style = styleGood;
// Apply the custom style to the "H" column.
worksheet.Columns["H"].Style = customStyle;
' Access the built-in "Good" MS Excel style from the Styles collection of the workbook.
Dim styleGood As Style = workbook.Styles(BuiltInStyleId.Good)
' Apply the "Good" style to a range of cells.
worksheet.Range("A1:C4").Style = styleGood
' Access a custom style that has been previously created in the loaded document by its name.
Dim customStyle As Style = workbook.Styles("Custom Style")
' Apply the custom style to the cell.
worksheet.Cells("D6").Style = customStyle
' Apply the "Good" style to the eighth row.
worksheet.Rows(7).Style = styleGood
' Apply the custom style to the "H" column.
worksheet.Columns("H").Style = customStyle
See Also