I use ClosedXML for exporting data into excel. The code is below
var workbook = new XLWorkbook();
var ws = workbook.Worksheets.Add(table, tabName);
using (MemoryStream memoryStream = new MemoryStream())
{
workBook.SaveAs(memoryStream);
memoryStream.WriteTo(Response.OutputStream);
memoryStream.Close();
}
If I am exporting 22000+ records, I got
OutofMemoryException at this line workBook.SaveAs(memoryStream);
Please suggest me a solution.
ClosedXML cannot export a big quantities of row and data and this is disadvantage of this library.
I recommend you to use OpenXML. It is another library able to export a large quantities of data.