We are facing the issue with Aspose (Version 23.6) Save methods with large amount of data. One of the file have around 1 million records and when we are using Aspose Save methods on server, it throws the null reference exception.
Below the code block which we are using to save the file
bool savelargefileconfig = ((dt != null) && (dt.Rows.Count > 0 ? Convert.ToString(dt.Rows[0][“LookUpValue”]) == “1” : false));
if (savelargefileconfig)
{
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(extensionOpions);
saveOptions.EnableZip64 = true;
saveOptions.ExportCellName = false;
Constant.PrepareWorkBook(ref wbook).Save(absoluteFilePath, saveOptions);
}
else
{
Constant.PrepareWorkBook(ref wbook).Save(absoluteFilePath, extensionOpions);
}
Observations :
- Method with the saveformat throws the exception with large amount of data.
- When we reduce the data to 200k , Method with the save options started saving the file but for bigger sample it breaks.
- We tried another format like xlsb but it did not help.
- This code is working fine in developer machine but breaking in server though the server has sufficient space and memory.
Exception Details :
System.NullReferenceException: Object reference not set to an instance of an object.
at Aspose.Cells.Workbook.Save(String fileName, SaveOptions saveOptions)
@santhoshsas,
Thanks for the details.
It is strange that your code works fine on the developer’s machine and does not work on the server. Could you please compare both machines’ configurations and check what is different with the server machine? Also, give us details like the OS and its version, .NET framework version, Aspose.Cells version (if it is different on the server machine), RAM of both machines, disk spaces, etc. We will check it soon. Please note that when you are saving a huge file having 1 million records in it, it will require lots of memory and CPU usage for sure. A rough estimate would be ten times or more memory than the size of the output Excel file is required.
Moreover, we recommend you to kindly try using the latest version/fix: Aspose.Cells for .NET v24.7 if it makes any difference. If you still find the issue, kindly give us a standalone sample application (source code without compilation errors), zip the project and post it, we will check it soon.
Hi Amjad,
please find below the details.
Operating system - Windows (Windows Server 2016 Standard) \ Microsoft Windows Server 2016 Datacenter
VM generation - V1
VM architecture - x64
Size - Standard D16s v4
vCPUs - 16
RAM - 64 GiB
DeviceID VolumeName Total (Gb)
A: 0.00
C: OS 256.00
E: App 153.00
.Net Framework : .Net 8
This issue is occurring when the workbook has 2.6 million records which is split between 11 tabs with 200 K records each.
@santhoshsas
Thank you for those details. We tried to simulate the scenario by filling 11 tabs with 260K(10K rows x 26 columns) records per sheet but found the process finished successfuly. Finaly we got one xlsx file of size about 20M.
Are you executing the program as standalone such as console application, or running it in other environments such as containers or web applications? If for both of the server and developer machine the program are executed as console application, maybe the issue can only be reproduced by some special data. Would you please provide us the original data and code so we can test it more? If it is not possible to provide the executable code and data, maybe you can provide us the generated xlsx by the developer machine so we can test more by simluating the data in the generated file.