Apple, from memory

Sorry for my English. I used the Epplus library and I really like it. But I have a problem: out of memory. It is necessary to write large amounts of data, no matter what. I want to know if it is possible to add the end of an Excel file that is not stored in everyone's memory. Or create multiple files and then merge into one file. Thanks in advance.

+4
source share
1 answer

1) if you are retrieving data from a database use datareader instead of datatable

2) write excel in a temporary file, delete it after completion (if it's a web environment, use response.writefile, and then delete it)

3) write a headline first, then add something like this to it (using my phone to print this)

var pck = new ExcelPackage(); var ws = pck.AddSheet("sheet1"); //write header here pck.saveas(fileinfo); pck.dispose(); // not sure if function existed pck= new excelpage(fileino.fullname); ws = pck.worksheets[1]; var rowIndex =0; while (reader.read()) { if (++rowindex % 100000 == 0) { // save and re-open } //write row here } pck.save(); //dispose / send file / delete file etc 
0
source

Source: https://habr.com/ru/post/1490888/


All Articles