Large documnets performance issue

Sep 24, 2012 at 9:53 PM

I have an ASP.NET MVC3 project and it uses OOXML and it takes a really long time to write an excel file with ~36,000 rows. I tried a bunch of different ways to speed this up to no avail. The bottleneck comes when writing to the document:

 

        private static void WriteValues(string cellLocation, string strValue, SpreadsheetDocument spreadSheet, WorksheetPart workSheet) {
            WorksheetWriter workSheetWriter = new WorksheetWriter(spreadSheet, workSheet);
            
            int intValue = 0;
            if (strValue.Contains("$")) {
                strValue = strValue.Replace("$", "");
                strValue = strValue.Replace(",", "");

                workSheetWriter.PasteValue(cellLocation, strValue, CellValues.Number);
            } else if (int.TryParse(strValue, out intValue)) {
                workSheetWriter.PasteValue(cellLocation, strValue, CellValues.Number);
            } else if (string.IsNullOrEmpty(strValue)) {
                workSheetWriter.PasteText(cellLocation, strValue);
            } else {
                workSheetWriter.PasteText(cellLocation, strValue);
            }
        }

The paste value is really inefficient here and I was wondering if there is anyway to create the row and just do an append?

 

Thank you!