Back to Devexpress

Table.Style Property

officefileapi-devexpress-dot-spreadsheet-dot-table-d91d1a46.md

latest7.5 KB
Original Source

Table.Style Property

Gets or sets the style applied to the table.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
TableStyle Style { get; set; }
vb
Property Style As TableStyle

Property Value

TypeDescription
TableStyle

A TableStyle object that specifies the table style.

|

Remarks

When you create a new table, the default table style (TableStyleCollection.DefaultStyle) is automatically applied to the created table. Use the Style property to format a table with any style from the TableStyleCollection collection. By default, the style collection contains a set of built-in styles similar to Microsoft Excel and the None style, which specifies clear table formatting. Built-in styles are defined with the BuiltInTableStyleId enumeration.

Example

The following code applies the BuiltInTableStyleId.TableStyleDark9 built-in style to a Table in a worksheet.

vb
spreadsheetControl1.BeginUpdate()
' Access the workbook's collection of table styles.
Dim tableStyles As TableStyleCollection = spreadsheetControl1.Document.TableStyles
' Access the built-in table style from the collection by its Id.
Dim tableStyle As TableStyle = tableStyles(BuiltInTableStyleId.TableStyleDark9)

' Apply the table style to the existing table.
Dim myTable As Table = spreadsheetControl1.ActiveWorksheet.Tables(0)
myTable.Style = tableStyle

' Show header and total rows.
myTable.ShowHeaders = True
myTable.ShowTotals = True
' Apply banded column formatting to the table.
myTable.ShowTableStyleRowStripes = False
myTable.ShowTableStyleColumnStripes = True

spreadsheetControl1.EndUpdate()
csharp
spreadsheetControl1.BeginUpdate();
// Access the workbook's collection of table styles.
TableStyleCollection tableStyles = spreadsheetControl1.Document.TableStyles;
// Access the built-in table style from the collection by its Id.
TableStyle tableStyle = tableStyles[BuiltInTableStyleId.TableStyleDark9];

// Apply the table style to the existing table.
Table myTable = spreadsheetControl1.ActiveWorksheet.Tables[0];
myTable.Style = tableStyle;

// Show header and total rows.
myTable.ShowHeaders = true;
myTable.ShowTotals = true;
// Apply banded column formatting to the table.
myTable.ShowTableStyleRowStripes = false;
myTable.ShowTableStyleColumnStripes = true;

spreadsheetControl1.EndUpdate();

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.

spreadsheet-document-api-examples-part2/CS/SpreadsheetDocServerAPIPart2/CodeExamples/TableActions.cs#L24

csharp
// Apply a built-in table style to the table.
table.Style = workbook.TableStyles[BuiltInTableStyleId.TableStyleMedium20];
#endregion #CreateTable

how-to-bind-a-worksheet-to-a-generic-list-or-a-bindinglist-data-source/CS/DataBindingToListExample/Form1.cs#L77

csharp
WorksheetTableDataBinding sheetDataBinding = sheet.DataBindings.BindTableToDataSource(weatherDatasource, bindingRange, dsOptions);
sheetDataBinding.Table.Style = spreadsheetControl1.Document.TableStyles[BuiltInTableStyleId.TableStyleMedium14];

spreadsheet-document-api-data-binding/CS/SpreadsheetApiDataBinding/Program.cs#L75

csharp
WorksheetTableDataBinding sheetDataBinding = worksheet.DataBindings.BindTableToDataSource(weatherDatasource, bindingRange, dsOptions);
sheetDataBinding.Table.Style = worksheet.Workbook.TableStyles[BuiltInTableStyleId.TableStyleMedium14];

spreadsheet-document-api-examples-part2/VB/SpreadsheetDocServerAPIPart2/CodeExamples/TableActions.vb#L21

vb
' Apply a built-in table style to the table.
            table.Style = workbook.TableStyles(BuiltInTableStyleId.TableStyleMedium20)
' #End Region ' #CreateTable

how-to-bind-a-worksheet-to-a-generic-list-or-a-bindinglist-data-source/VB/DataBindingToListExample/Form1.vb#L80

vb
Dim sheetDataBinding As WorksheetTableDataBinding = sheet.DataBindings.BindTableToDataSource(weatherDatasource, bindingRange, dsOptions)
sheetDataBinding.Table.Style = spreadsheetControl1.Document.TableStyles(BuiltInTableStyleId.TableStyleMedium14)

spreadsheet-document-api-data-binding/VB/SpreadsheetApiDataBinding/Program.vb#L67

vb
Dim sheetDataBinding As WorksheetTableDataBinding = worksheet.DataBindings.BindTableToDataSource(weatherDatasource, bindingRange, dsOptions)
sheetDataBinding.Table.Style = worksheet.Workbook.TableStyles(BuiltInTableStyleId.TableStyleMedium14)

spreadsheet-document-api-import-data-from-data-sources/VB/DataImportExample/Form1.vb#L106

vb
' Format the table by applying a built-in table style.
table.Style = worksheet.Workbook.TableStyles(BuiltInTableStyleId.TableStyleMedium27)

See Also

Spreadsheet Tables

Table Interface

Table Members

DevExpress.Spreadsheet Namespace