Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: Slow wb.Worksheets.Add() with big datatable

$
0
0
Hi,

I am using ClosedXML wb.Worksheets.Add() to create a worksheet from a datatable the has over 100,000 rows and 59 columns in an ASP.Net web site. The code is running on a Windows Server 2008 R2 64bit machine. The process to create the worksheet is taking 10 - 15 minutes but it is always successful. Understandably the end users don't like the wait.

Is there anything that I can do to speed up the process?

I've included the code below.

Thanks,

Dave
XLWorkbook wb = new XLWorkbook();

            // Add a DataTable as a worksheet
            wb.Worksheets.Add(UserControls_ProductionExcelOutput.MatrixPROCOutputdt, "ProdMatrixOutput");
            wb.Worksheets.First().Tables.First().ShowAutoFilter = false;

            // Prepare the response
            Response.Clear();
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            //httpResponse.AddHeader("content-disposition", "attachment;filename=\"" + (String)Session["MatrixOutputFileName"] + "\"");
            Response.AddHeader("content-disposition", "attachment;filename=" + (String)Session["MatrixOutputFileName"]);

            //httpResponse.AddHeader("content-disposition", "attachment;filename=\"Prod_Matrix_Output.xlsx\"");

            // Flush the workbook to the Response.OutputStream
            using (MemoryStream memoryStream = new MemoryStream())
            {
                wb.SaveAs(memoryStream);
                memoryStream.WriteTo(Response.OutputStream);
                memoryStream.Close();
            }
Response.End();

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>