Exporting to multiple excel worksheets from asp.net?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I'm using ASP.NET 1.1 and trying export a dataset with multiple datatables
(each to it's own Excel worksheet.)

I've successful bound a DataTable a DataGrid using the code below but I
don't know how to create multiple worksheets tabs to correspond to each
datatable.

Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
StringWriter sw = new StringWriter();
HtmlTextWriter ht = new HtmlTextWriter(sw);
DataGrid1.RenderControl(ht);
Response.Write(sw.ToString());
Response.End();
 
I'm using ASP.NET 1.1 and trying export a dataset with multiple datatables
(each to its own Excel worksheet.)

No problem.
I've successfully bound a DataTable a DataGrid using the code below but I
don't know how to create multiple worksheets tabs to correspond to each
datatable.

Ah, well for that you have two choices:

1) Use the Excel XML schema file format:
http://www.microsoft.com/downloads/...52-3547-420a-a412-00a2662442d9&displaylang=en

2) Use a 3rd-party product like this:
http://www.aspose.com/Products/Aspose.Cells/Default.aspx

Don't consider trying to use Office automation, though... it's not designed
for this kind of scneraio, and Microsoft strongly advise against it to the
extent that they will not support any application which uses it:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2
 
Back
Top