Skip to main content
.NET Framework 4.5.2+

StyleCollection Interface

A collection of cell styles in the workbook.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v23.1.Core.dll


public interface StyleCollection :


The StyleCollection object is a collection of styles available in the workbook to format cells. Use the IWorkbook.Styles property to access this object.

This collection includes a set of built-in styles similar to Microsoft® Excel® that can be obtained by their identifiers (the BuiltInStyleId enumeration members) and custom styles that can be accessed by their names (Style.Name). Built-in cell styles are contained in the collection by default (including the Normal style, which is applied to all unformatted cells), while custom styles can be added via the StyleCollection.Add method. You can also duplicate built-in styles using the Style.CopyFrom method and modify existing styles by changing the properties of the corresponding Style object within the Formatting.BeginUpdate - Formatting.EndUpdate method pair. For details, see the How to: Create or Modify a Style example.


This example demonstrates how to format a cell, a range of cells, an entire row or an entire column by applying a style.

  1. Access the 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.
  2. Assign the required style object to the CellRange.Style property of the cell, cell range, row or column object.

View Example

// 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;
See Also