Hi,
I have a requirement where I need to create and excel file with 15000 records and 300 columns.
When I try to save the file using the following code
using (var fileData = new System.IO.FileStream(fileName, System.IO.FileMode.Create))
{
workbook.Write(fileData);
}
it is failing with OutOfMemoryException.
My question is how can I save large files (>30MB).
Thanks
Vijay
Comments: ** Comment from web user: ebyrob **
I have a requirement where I need to create and excel file with 15000 records and 300 columns.
When I try to save the file using the following code
using (var fileData = new System.IO.FileStream(fileName, System.IO.FileMode.Create))
{
workbook.Write(fileData);
}
it is failing with OutOfMemoryException.
My question is how can I save large files (>30MB).
Thanks
Vijay
Comments: ** Comment from web user: ebyrob **
In Apache POI there is a serialized version of at least the XSSF side of things.
org.apache.poi.xssf.streaming.SXSSFWorkbook
I don't see this implemented in NPOI currently, but I'm hoping sometime in the future this can be ported over to C#.
Note: I'm having the same problem you are, but with reading a large XLSX file:
FileStream fs = new FileStream("foo.xlsx", FileMode.Open);
NPOI.SS.UserModel.IWorkbook wb = new NPOI.XSSF.UserModel.XSSFWorkbook(fs);
OutOfMemoryException (on 50 meg file using 1.7 gigs in process) at XSSFWorkbook constructor.