Partilhar via


WorkbookBase.DefaultTableStyle Property

Gets or sets the table style from the TableStyles property that is used as the default style for tables in the workbook.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Syntax

'Declaration
Public Property DefaultTableStyle As Object
public Object DefaultTableStyle { get; set; }

Property Value

Type: System.Object
The table style from the TableStyles property that is used as the default style for tables in the workbook.

Examples

The following code example sets the default style of tables to Table Style Dark 11, which is a style that is available in Excel on the Design tab in the Table Styles group when a table is selected. The example then adds a table to verify the new table style.

This example is for a document-level customization.

Private Sub SetTableStyle()
    Me.DefaultTableStyle = Me.TableStyles("TableStyleDark11")

    ' Add a table to verify the new default table style 
    Dim myTable As Microsoft.Office.Tools.Excel.ListObject = _
    Globals.Sheet1.Controls.AddListObject( _
        Globals.Sheet1.Range("A1", "B3"), "myTable")
End Sub
private void SetTableStyle()
{
    this.DefaultTableStyle = this.TableStyles["TableStyleDark11"];

    // Add a table to verify the new default table style
    Microsoft.Office.Tools.Excel.ListObject myTable =
    Globals.Sheet1.Controls.AddListObject(
        Globals.Sheet1.Range["A1", "B3"], "myTable");
}

.NET Framework Security

See Also

Reference

WorkbookBase Class

Microsoft.Office.Tools.Excel Namespace