We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

SetDataSource


Hello,

I am attempting to create a designerworkbook using smart tags. I have set the datasource using SetDataSource( MyDataSet). My dataset has 3 tables that have the same column names. I want to access the data in table 2. How do I do this? Does this tool only support a single datatable at a time?


This message was posted using Page2Forum from WorkbookDesigner.SetDataSource Method (DataSet) - Aspose.Cells for .NET and Java

Hi,

Well, no it can handle multiple datatables at a time.

May the following sample code help you for your need. Attached are the input and output files. I used Northwind.mdb Access sample database.

OleDbConnection con = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=f:\\test\\Northwind.mdb");
con.Open();
OleDbCommand cmd = new OleDbCommand("Select * from Products", con);
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = cmd;

DataSet ds = new DataSet();
da.Fill(ds, "Products");
DataTable dt = ds.Tables["Products"];

cmd = new OleDbCommand("Select * from Customers", con);
da.SelectCommand = cmd;
da.Fill(ds, "Customers");
DataTable dt1 = ds.Tables["Customers"];

WorkbookDesigner wd = new WorkbookDesigner();
wd.Open("f:\\test\\booksources.xls");//tProductss.xls");
wd.SetDataSource(dt);
wd.SetDataSource(dt1);
wd.Process();

wd.Save("f:\\test\\out_booksources.xls");

For further ref, please check: http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/smart-markers.html

Thank you.