1

I have a large dataset (100,000 rows, 33 columns). I am using OpenXML to take this data and write it to Excel using the method explained here Export big amount of data from XLSX - OutOfMemoryException

It appears to store all of the data in memory when creating the Excel file and then write it all at once because of the XMLWriter. Even in the example above without my own data it appears that this using 700MB-1GB before it finally writes the data.

Is there a way to clear the buffer periodically to limit memory usage or does it have to be all in 1 XMLWriter with how OpenXML works

mameesh
  • 3,651
  • 9
  • 37
  • 47
  • I hope you aren't working on the UK NHS track and trace app :-) https://www.itpro.co.uk/business-strategy/public-sector/357325/nhs-test-and-trace-technical-issue-excel-glitch – Neil Mar 15 '21 at 16:34
  • 2
    Are you using .NET Core? If so, you could be running into [this issue](https://github.com/OfficeDev/Open-XML-SDK/issues/807) which in turn is caused by [this issue](https://github.com/dotnet/runtime/issues/1544). Unfortunately I don't think there's a fix (other than reverting to the .NET Framework which uses a different System.IO.Packaging). – petelids Mar 17 '21 at 11:58
  • 1
    @Petelids, you are correct, I just tested this in .Net 4.5 vs .NetCore and its a huge difference in the hundreds of MBs – mameesh Mar 17 '21 at 16:05

0 Answers0