Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
SourceType Property

ListObject.SourceType Property

Gets the current source of the list.

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

XlListObjectSourceType SourceType { get; }

Property Value

Type: XlListObjectSourceType
One of the XlListObjectSourceType values.

The following code example creates a DataTable and a ListObject, and then binds the ListObject to the DataTable. It then displays the source of the list in a message.

This example is for a document-level customization.

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

    // Get the source type and display it in a message.
    MessageBox.Show("The source type of list1 is " +
        list1.SourceType.ToString() + ".");

© 2015 Microsoft