Re: How to map a dataset table to an Excel list object?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Bob,

You can think of the ListObject as a DataGrid... which can be Databound to a
DataSet or DataTable....

So it looks something like...

MyListObject.DataSource = MyDataSet;
MyListObject.DataMember = "MyDataTable";

When instantiating the ListObject before the above, you pass the range, and
give it a name in the constructor.

Globals.Sheet1.Controls.AddListObject(Globals.Sheet1.Range["$A$4", "$D$4"],
"ReportData");

You'll see this creates a ListObject... A B C D... 4 columns across... if
you need to be more flexible, then obviously, work something out to
calculate the Range references as a string before passing it in.

Calvin

You can have it default to the DataTable
<BSegE@xxxxxxxxxxxxxxxxx> wrote in message
news:part1of1.1.Dno4Ip5V%23ptG7A@xxxxxxxx
Hello Everyone,

I am trying to develop an Excel template using VSTO 2005.

I have collected data from a web service and have it stored as
a table in a local dataset. What I need to do next is display the
contents of the data table on my spread***. My preference
would be to use an Excel list object to do this.

Can anyone tell me how to map a dataset table to a list object?

A code sample, pointer or any other guidance would be a big
help.

Bob


.


Quantcast