Answered by:
Export to Excel delay when records are too big & formatted

Question
-
User-1578974752 posted
Hi
Here the values are above 2000 and hece it is taking 4 minutes to open the Excel sheet & some time hang. How can I improve the speed?
if (Session["dse"] != null)
{
ASPEXCELL.ExcelExport.ExportDataSetToExcel((DataSet)Session["dse"], "Data_" + DateTime.Now.ToString() + ".xls");
}
Thanks
Monday, April 12, 2021 2:35 AM
Answers
-
User-821857111 posted
You might find that working directly with Excel is quicker: https://www.mikesdotnetting.com/article/278/a-better-way-to-export-gridviews-to-excel
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, April 16, 2021 5:18 AM
All replies
-
User409696431 posted
What is the code behind "ASPEXCELL.ExcelExport.ExportDataSetToExcel". Are you using a library, and if so, which one?
Is there a reason you are storing the data in session, which may cause memory issues if the dataset is large?
Monday, April 12, 2021 9:09 AM -
User-1578974752 posted
Below is my code in that specific code. it is in a repeater as below.
protected void ExportToExcel(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=RepeaterExport.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
rptCustomers.RenderControl(hw);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
}
Thursday, April 15, 2021 9:43 AM -
User409696431 posted
ExportToExcel exports the contents of a control, rptCustomers.
How does that relate to ExportDataSetToExcel, which has as its parameters a dataset in Session and an .xls filename?
And what do you mean that ExportToExcel is in a repeater? Is it called for each line of the repeater?
Regardless, if you are handling a large amount of data it will take more time than a small small amount of data. There is not much you can do about it as far as the ExportToExcel portion goes.
Friday, April 16, 2021 4:24 AM -
User-821857111 posted
You might find that working directly with Excel is quicker: https://www.mikesdotnetting.com/article/278/a-better-way-to-export-gridviews-to-excel
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, April 16, 2021 5:18 AM