Export data from gridview to different excel tables

I bind data from a dataset to a grid and export the data from the grid to excel. If the number of items in the grid is greater than 50,000, an error message is displayed.

So, I want to split the data and display it in different sheets in excel. (I work in a web application)

using this code to export to excel

gvExcel.DataSource = DTS; gvExcel.DataBind(); Response.AddHeader("content-disposition", "attachment; filename= filename.xls"); Response.ContentType = "application/excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); gvExcel.RenderControl(htw); // Style is added dynamically Response.Write(style); Response.Write(sw.ToString()); Response.End(); 

Can someone help me with this?

0
source share
2 answers

Pretty sure, you need to use the Excel API and create a document, not just its HTML version. Using HtmlTextWriter is a bit disastrous, and I hate downloading documents that use it, because it's always a mess. I have to re-save it as xls (because its really just HTML) and go through the process of fixing it.

0
source
0
source

All Articles