Hello,
I use OpenXML SDK 2.0 to generate Excel file with large amount of data, appox. 1000000 rows, and I need to optimize memory usage because my machine slow down very fast.
I want to solve this issue by flushing part of generated DOM tree into file in runtime. I make my own buffering for data. E.g I have 100000 records to write and I want flush stream into file when I add 1000 rows into Excel worksheet. I make this by using method worksheetPart.Worksheet.Save(). Documantation says taht this method Save(): "saves the data in the DOM tree back to the part. It could be called multiple times as well. Each time it is called, the stream will be flushed. "
foreach (Record m in dataList)
{
Row contentRow = CreateContentRow(index, m); // my own method to create row content
//Append new row to sheet data.
sheetData.AppendChild(contentRow);
if (index % BufferSize == 0)
{
worksheetPart.Worksheet.Save();
}
index++;
}
This method works because memory usage chart has saw shape but unfortunetly the memory uasge grows in time.
Do anyone have any idea how solve this issue?