Exporting to multiple excel worksheets from asp.net?

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();
 
M

Mark Rae

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top