I have a tabbed series of grids on a data preview page. I now need to import the data from each grid into its own sheet in an Excel workbook.
How could I do this?
BTW, this is on a Mac or a PC.
I have a tabbed series of grids on a data preview page. I now need to import the data from each grid into its own sheet in an Excel workbook.
How could I do this?
BTW, this is on a Mac or a PC.
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 single work book then you will have to use a dll.
I've done this in two ways in the past:
Using Excel automation, and using the Excel API on a server to create multiple sheets. (Not recommended, but it does work.)
Create the XML you would see when you save the equivalent spreadsheet in Excel and upload it as per Samiksha's suggestion.
Normally I create a template in Excel, save as XML, then I alter the contents of it depending on the data I want to display.