ListObject.DataBoundFormat Property


Gets or sets the format style for data-bound ListObject controls.

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

XlRangeAutoFormat DataBoundFormat { get; set; }

The ListObject control must be bound to data before you can use this property.

The specified format is applied to the entire list object, including rows that are added later.

To remove formatting, set DataBoundFormat to xlRangeAutoFormatNone.

Use DataBoundFormatSettings to exclude specific types of formatting such as pattern, font, or width from the style.

The following code example creates a DataTable and a ListObject, and binds the ListObject to the DataTable. It then uses an XlRangeAutoFormat value to format the ListObject.

This example is for a document-level customization.

private void ListObject_DataBoundFormat()
    // 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",

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