Hi,
I am using Aspose.Cells 7.1.0.0.
Machine config:
Quad Core
16 GB
To write 1 million rows ( each row having 26 columns) to xlsx file, it takes 9 mins:
_worksheetInstance.Cells.ImportDataTable(currentTable, IsHeaderRequired, (IsHeaderRequired ? 15 : 0), 0, initialTable.Rows.Count, initialTable.Columns.Count, false, “yyyy/MM/dd”, true);
I have divided 1 million rows into 4 chunks and tried to write using TPL in the same worksheet which gave different errors like Index out of Array, System .Out.of Memory Exception at different times.
Using Light Cells API , time taken has reduced to 6 mins.
Is there any way to reduce the time for excel generation further?
Also how to use LightCells API for xls, because when I am providing SaveFormatType of xls, data is not saved in excel.
ooxmlSaveOptions = new OoxmlSaveOptions(SaveFormat.Excel97To2003);
ooxmlSaveOptions.LightCellsDataProvider = new TestDataProvider(_workbook, resultSet.Tables[0].Rows.Count +(IsHeaderRequired?16: 0), resultSet.Tables[0].Columns.Count,resultSet.Tables[0],tableHeader,IsHeaderRequired);
Regards,
Ranadeep
Thanks Babar, for your reply.
I was able to generate xlsx files really fast using Aspose Light Cells API but unable to generate xls using Aspose Light Cells.
Little Background:
I need to support both xls and xlsx in my application and app should be able to generate 5 million plus records. So if user selects xls/xlsx then multiple xls/xlsx files will be generated each having 65,000/1 million rows. I am using TPL and each thread will call sp to return 65,000/1 million rows based on xls/xlsx and write into files.
Aspose .Light Cells helps me to generate 5 million xlsx files ( i.e. 5 xlsx files) in 17 mins, using TPL,which is pretty good.
I would like to use Aspose Light Cells for xls as well but unable to.
Whenever I use:
var ooxmlSaveOptions = new OoxmlSaveOptions(SaveFormat.Excel97To2003);
ooxmlSaveOptions.LightCellsDataProvider = new TestDataProvider(_workbook, resultSet.Tables[0].Rows.Count +(IsHeaderRequired?16: 0), resultSet.Tables[0].Columns.Count,resultSet.Tables[0],tableHeader,IsHeaderRequired);
I get blank file even for Aspose 8.3.0.0.
Hi Randeep,
Thank you for trying out the latest version of Aspose.Cells for .NET 8.3.0, and we are glad to know that you are able to observe the improvement in performance while generating XLSX file.
In order to troubleshoot your recently shared scenario (creation of blank XLS), we would request you to please submit an executable standalone application replicating the problem with latest version of Aspose.Cells for .NET 8.3.0. Please note, we need the sample application to re-create the exact sequence of routines that is causing the problem on your side. Moreover, if you are importing the data directly from database, we would request you to dynamically create an equivalent/similar data source within your code/sample application so that we do not require the database connectivity to investigate the matter on our end.
Thank you for your cooperation & understanding.
Hi Babar,
Please find attached a console application using xls and Light cells API.
Regards,
Ranadeep
Hi Ranadeep,
Many thanks for the sample application. We are currently looking into the matter, and we will shortly get back to you with updates in this regard.
Hi Ranadeep,
Thank you for your patience.
Please make the following changes in your code (highlighted in red) and it should work perfectly for the XLS spreadsheet format.
C#
var saveOptions = new Aspose.Cells.XlsSaveOptions(); //new OoxmlSaveOptions(SaveFormat.Excel97To2003);
saveOptions.LightCellsDataProvider = new TestDataProvider(book, table.Rows.Count, table.Columns.Count, table);
book.Save(“D:/output.xls”, saveOptions);
Thanks a ton, Babar!!! You guys are really prompt and it worked!!!
However it will be good if the same class is giving both xls and xlsx light cells option as that will help to write cleaner code.
Regards,
Ranadeep
Hi Ranadeep,
Good to know that you are up & running.
Each Aspose.Cells’ SaveOptions class represents a distinct file format so it’s best to keep the format specific traits in separate classes. This is also because Aspose.Cells APIs provide the conversion to non-spreadsheet file formats such as follow.
- HtmlSaveOptions
- ImageSaveOptions
- PdfSaveOptions
- TxtSaveOptions
- PdfSaveOptions
- XpsSaveOptions
Please note that specifying SaveFormat parameter is optional while using any of the SaveOptions classes.