How to: Fill ListObject Controls with Data
You can use data binding as a way to quickly add data to your document. After binding data to a list object, you can disconnect the list object so it displays the data but is no longer bound to the data source.
Applies to: The information in this topic applies to document-level projects and VSTO add-in projects for Excel. For more information, see Features Available by Office Application and Project Type.
For a related video demonstration, see How Do I: Create a List in Excel that is Connected to a SharePoint List?.
To bind data to a ListObject control
Add sample columns and data in the Startup event handler of the Sheet1 class (in a document-level project) or ThisAddIn class (in an application-level project).
Call the SetDataBinding method and pass in the column names in the order they should appear. The order of the columns in the list object can differ from the order in which they appear in the DataTable.
To disconnect the ListObject control from the data source
Compiling the Code
This code example assumes you have an existing ListObject named list1 on the worksheet in which this code appears.
Extending Word Documents and Excel Workbooks in VSTO Add-ins at Run Time
Controls on Office Documents
Adding Controls to Office Documents at Run Time
How to: Map ListObject Columns to Data
Automating Excel by Using Extended Objects
Binding Data to Controls in Office Solutions
How to: Populate Worksheets with Data from a Database
How to: Populate Documents with Data from Services