Back to Devexpress

StyleCollection.DefaultStyle Property

officefileapi-devexpress-dot-spreadsheet-dot-stylecollection.md

latest4.7 KB
Original Source

StyleCollection.DefaultStyle Property

Returns the Normal style that is applied to cells by default.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
Style DefaultStyle { get; }
vb
ReadOnly Property DefaultStyle As Style

Property Value

TypeDescription
Style

A Style object specifying the Normal style.

|

Remarks

Use the DefaultStyle property to access the Normal built-in style that is automatically included in the StyleCollection collection and applied to all unformatted cells in the workbook by default. This style can be also accessed from the StyleCollection collection by the style name (“Normal”) or index (0).

Example

This example demonstrates how to remove all formatting from a cell or range of cells. You can do this in one of the following ways.

csharp
using DevExpress.Spreadsheet;
// ...

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];

// Call the ClearFormats method.
worksheet.ClearFormats(worksheet.Range["A1:C4"]);

// Apply the Normal style to cells.
worksheet.Cells["D6"].Style = workbook.Styles[0];
worksheet.Range["F3:H4"].Style = workbook.Styles[BuiltInStyleId.Normal];
worksheet.Rows[7].Style = workbook.Styles["Normal"];
worksheet.Columns["K"].Style = workbook.Styles.DefaultStyle;
vb
Imports DevExpress.Spreadsheet
' ...

Dim workbook As New Workbook()
Dim worksheet As Worksheet = workbook.Worksheets(0)

' Call the ClearFormats method.
worksheet.ClearFormats(worksheet.Range("A1:C4"))

' Apply the Normal style to cells.
worksheet.Cells("D6").Style = workbook.Styles(0)
worksheet.Range("F3:H4").Style = workbook.Styles(BuiltInStyleId.Normal)
worksheet.Rows(7).Style = workbook.Styles("Normal")
worksheet.Columns("K").Style = workbook.Styles.DefaultStyle

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DefaultStyle 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.

spreadsheet-document-api-examples-part1/VB/SpreadsheetExamples/SpreadsheetActions/CellActions.vb#L225

vb
worksheet.ClearFormats(worksheet("C4"))
worksheet("D4").Style = workbook.Styles.DefaultStyle
' Remove hyperlinks from cells.

See Also

How to: Apply a Style to a Cell or Range of Cells

How to: Create or Modify a Cell Style

How to: Clear Cell Formatting

StyleCollection Interface

StyleCollection Members

DevExpress.Spreadsheet Namespace