officefileapi-devexpress-dot-spreadsheet-dot-cellrange-e30385e4.md
Gets or sets the style applied to the current range of cells.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
Style Style { get; set; }
Property Style As Style
| Type | Description |
|---|---|
| Style |
A Style object that specifies the cell style. If the range includes cells formatted in different styles, the Style property of this range object returns null (Nothing in VB).
|
By default, the Normal style is applied to worksheet cells (such cells are considered as unformatted). However, you can apply any built-in or custom style from the IWorkbook.Styles collection to a cell or cell range by assigning the corresponding Style object to the Style property.
For more information on how you can change cell appearance, see the Formatting Cells and Conditional Formatting documents.
This example demonstrates how to format a cell, a range of cells, an entire row or an entire column by applying a style.
CellRange.Style property of the cell, cell range, row or column object.// 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
The following code snippets (auto-collected from DevExpress Examples) contain references to the Style property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
header[1].Value = "Value";
header.Style = workbook.Styles[BuiltInStyleId.Accent2];
header[1].Value = "Value";
header.Style = workbook.Styles[BuiltInStyleId.Accent2];
header[1].Value = "Value";
header.Style = workbook.Styles[BuiltInStyleId.Accent2];
header.ColumnWidthInCharacters = 30;
header.Style = workbook.Styles["Heading 1"];
#endregion #SimpleSort
header(1).Value = "Value"
header.Style = workbook.Styles(BuiltInStyleId.Accent2)
#Region "#Built-inProperties"
header(1).Value = "Value"
header.Style = workbook.Styles(BuiltInStyleId.Accent2)
header(1).Value = "Value"
header.Style = workbook.Styles(BuiltInStyleId.Accent2)
header.ColumnWidthInCharacters = 30
header.Style = workbook.Styles("Heading 1")
' #End Region ' #SimpleSort
See Also