Version: Infragistics.Documents.Excel V12.2 as Excel2007 format
Scenario:
In our trading app, there is a requirement to save all application related data (All Screens in the app) to be saved onto an Excel file so that the users can refer to it at a later date as to what data was exactly used for valuation and if required change it re-run it through the application to see the results.
So the output file cant be any other format other than excel as per the requirement.
So to save the application data, we use the Workbook object, create worksheets and add data by looping through the data object and set the cell value of the worksheet.
Problem:
Some of the screens in the application contain trade sensitivities data which is around approx 700 thousand rows which need to be written to the excel worksheet.
The issue we face is that the Workbook object contains all the worksheets and the Workbook.Save() method requires all sheets to be in the workbook object at the point of save, we get a out of memory exception when writing the huge number of records.
We are not able to write sheet by sheet to the workbook by subsequently clearing the worksheets.
Is there a way to get around this issue by not having all the worksheets in the workbook to be able to save or can we append worksheets to an existing file?
Please suggest a way out to deal with out of memory issue in this case.
Its great!
Hello Kannan,
We are looking forward to hear from you.
Thanks a lot, am trying your ideas to see if that can help,
will post update.
Hello,
I am just checking your progress on the issue that you are having.
If you require any further assistance please do not hesitate to ask.
I have been further investigating this and after contacting with our development team and you can reduce the memory that the application is consuming, by using the SetCellValue method of the WorksheetRow, instead of using WorksheetCell.Value property:
worksheetRow.SetCellValue(++currentCell, i.Value);
This will reduce the memory allocated for the WorksheetCell objects and can improve the overall memory usage. Also if most of the Cells in column using the same format you can change the format of the column instead of the Cells for example
’worksheet.Columns[0].CellFormat.Alignment = HorizontalCellAlignment.Left’