Hey guys,
I am working on a project where I am using a DataReader to read large amounts of data (100,000+ rows, 20+ column) and am streaming those into a worksheet using the SAX OpenXmlWriter methods to avoid high memory usage. This is working very fast and efficiently so far as I can tell. However, as I am writing these values I am also storing the maximum length outputted in each column so I can then go on and update the Columns collection in the worksheet to set appropriate default widths when the spreadsheet is opened in Excel. Very frustratingly the Columns collection is BEFORE the SheetData meaning that there seems to be no way to update it after writing all my data! If I try to access the Columns collection via the DOM then it loads the whole spreadsheet into memory and causes my app to crash with an OutOfMemoryException.
Do you guys know of any clever way of updating the Columns collection once the SheetData has finished being outputted without forcing the whole document to be loaded into memory or having to go through the WHOLE spreadsheet with an OpenXmlReader and then output it all again to a new sheet with a separate OpenXmlWriter? Any help would be much appreciated.
Cheers,
James.