I have a complex object (tree structure) that I flatten it as a datatable in order to display it on an excel sheet. The datatable is huge and has about 20,000 rows and 10,000 columns.
Writing data to the excel cell one at a time was accepted forever. So, I convert the complex object to datatable and then write it to excel sheet using the following code.
Is it possible to write 20K rows x 10K columns per excel sheet quite quickly in less than a minute or, 5 minutes? What is the best way to quickly complete this task.
Environment: Visual Studio 2010, VSTO project excel workbook, .net framework 4.0, excel 2010/2007
EDIT:
The source data source is the response of the recreation service in json format. Then I deserialize the json response into C # objects and finally flatten it into a datatable.
Using this code to write data to an excel sheet:
Excel.Range oRange; var oSheet = Globals.Sheet3; int rowCount = 1; foreach (DataRow dr in resultsDataTable.Rows) { rowCount += 1; for (int i = 1; i < resultsDataTable.Columns.Count + 1; i++) {
Final Solution: Used an array of 2D objects instead of a datatable and wrote it in a range.
source share