Convert datatables in ASP.NET to different Excel SHEETS

2

How can I create more than sheets converting different datatable to excel? My code:

DataTable dt = new DataTable();

        dt = Tr.Get();
        GridView x = new GridView();
        x.DataSource = dt;
        x.DataBind();
        Response.Clear();
        x.HeaderStyle.Font.Size = 8;
        x.RowStyle.Font.Size = 10;

        Response.AddHeader("content-disposition", "attachment;filename=s.xls");
        Response.ContentType = "application/excel";

        StringWriter stringWriter = new StringWriter();
        HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);

        x.RenderControl(htmlTextWriter);

        Response.Write(stringWriter.ToString());

        Response.End();
    
asked by anonymous 19.04.2014 / 15:25

1 answer

0

I believe that in your case, a good solution would be to use EpPlus that is available via NuGet

More details on this other StackOverflow issue:

p>     
20.04.2014 / 01:45