We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to add more than one datatable?

Hi,
I want to export data to excel file.

I tried with ImportDataTable method. I am able to successfuly import datatable to the excel. But as I tries to import other table it overwrites the previous data.

Is there any way so that I can import datatable one by one to the excel. i.e. I should be able to append tables to excel.

Thanks,
Sandeep

3 Replies

CP Chella Pandian B Syncfusion Team November 24, 2006 04:40 PM UTC

Hi Sandeep

You can append as many data tables in a sheet by changing it row value.

sheet.ImportDataTable (dataTable, false, 1, 1, -1, -1);

sheet.ImportDataTable (dataTable, false, sheet.Rows.Length +2 , 1, -1, -1);

sheet.ImportDataTable (dataTable, false, sheet.Rows.Length +2, 1, -1, -1);

Let me know any other difficulties.

With regards,
Chella.


SA Sandeep November 27, 2006 05:41 AM UTC


Hi Chella,

Thank you very much. It solved my problem.
But now I want to some more things with this.

Situations is like this.
I have suppose ten datatables.
I will import one by one.
But before every table I want to give some details about table like header.
How I can add individual row in Excel Sheet for this. I tried with insertrow but I am not able to add data to it.

Please provide me the solution.

Thanks,
Sandeep


CP Chella Pandian B Syncfusion Team November 27, 2006 05:37 PM UTC

Hi Sandeep

Adding some text in-between the Data table can be done using the following code.

sheet.Range[1,1].Text = "Table Header 1";
sheet.ImportDataTable (dt, false, 2, 1, -1, -1);

sheet.Range[sheet.Rows.Length+2,1].Text = "Table Header 2";
sheet.ImportDataTable (dt, false, sheet.Rows.Length+2 , 1, -1, -1);

sheet.Range[sheet.Rows.Length+2,1].Text = "Table Header 3";
sheet.ImportDataTable (dt, false, sheet.Rows.Length+2 , 1, -1, -1);

Let me know whether this what you where looking at. Thanks for using XlsIO.

With Regards,
Chella.

Loader.
Live Chat Icon For mobile
Up arrow icon