FormatSettings Enumeration


Specifies the type of formatting that is applied to the ListObject when it is bound to data.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

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

public enum FormatSettings

Member nameDescription

Indicates whether to include an alignment in the predefined XlRangeAutoFormat.


Indicates whether to include border formats in the predefined XlRangeAutoFormat.


Indicates whether to include font formats in the predefined XlRangeAutoFormat


Indicates whether to include the number formats in the predefined XlRangeAutoFormat.


Indicates whether to include the pattern formats in the predefined XlRangeAutoFormat.


Indicates whether to include the column width and row height in the predefined XlRangeAutoFormat.

There are six settings that combine to specify formatting. Using this enumeration, you can select which settings to apply to the ListObject. By default all format settings are applied.

The following code example creates a DataTable and a ListObject, and binds the ListObject to the DataTable. It then applies the font and pattern formats of a predefined XlRangeAutoFormat value to the ListObject.

This example is for a document-level customization.

private void ListObject_DataBoundFormatSettings()
    // Create a new DataSet and DataTable.
    DataSet ds = new DataSet();
    DataTable dt = ds.Tables.Add("Customers");
    dt.Columns.Add(new DataColumn("LastName"));
    dt.Columns.Add(new DataColumn("FirstName"));

    // Add a new row to the DataTable.
    DataRow dr = dt.NewRow();
    dr["LastName"] = "Chan";
    dr["FirstName"] = "Gareth";

    // Create a list object.
    Microsoft.Office.Tools.Excel.ListObject list1 = 
        this.Range["A1"], "list1");

    // Bind the list object to the DataTable.
    list1.AutoSetDataBoundColumnHeaders = true;
    list1.SetDataBinding(ds, "Customers", "LastName",

    // Specify the format settings that you want to include.
    // In this example, only the Font and Pattern 
    // settings are applied.
    list1.DataBoundFormatSettings =
        Microsoft.Office.Tools.Excel.FormatSettings.Font |

    // Add a format to the list object.
    list1.DataBoundFormat = 
Return to top