How to create a multi-page Excel workbook on a client machine?

I have a table with grids in a data preview page. Now I need to import data from each grid into my sheet in Excel workbook.

How can i do this?

By the way, this is on a Mac or PC.

0


source to share


2 answers


In the past, I have done this in two ways:



  • Using Excel Automation and using the Excel API on the server to create multiple sheets. (Not recommended, but it works.)

  • Generate the XML you see when you save the equivalent spreadsheet in Excel and load it as suggested by Samikshi.

    I usually create a template in Excel, save it as XML, and then change its content depending on the data I want to display.

+1


source


This is for .net C #

Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition:", "attachment;filename=filename.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new  System.Web.UI.HtmlTextWriter(oStringWriter);
this.ClearControls(Grid);
Grid.RenderControl(oHtmlTextWriter);

      



If you want to create multiple sheets in one workbook you will have to use dll.

+1


source







All Articles