Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

FormatSettings Enumeration

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

Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in microsoft.office.tools.excel.dll)

public enum FormatSettings

 Member nameDescription
AlignmentIndicates whether to include an alignment in the predefined XlRangeAutoFormat
BorderIndicates whether to include border formats in the predefined XlRangeAutoFormat
FontIndicates whether to include font formats in the predefined XlRangeAutoFormat 
NumberIndicates whether to include the number formats in the predefined XlRangeAutoFormat
PatternIndicates whether to include the pattern formats in the predefined XlRangeAutoFormat
WidthIndicates 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.

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", missing], "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 = 

© 2015 Microsoft