We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

OutOfMemory Exception is thrown using Aspose.Cells

i have an issue with aspose.cells control

in my object contains 300000 records with 60+ columns. when i am trying to write this data to xlsx, OutOfMemory Exception is thrown

how can we resolve this issue?

This message was posted using Email2Forum by Tahir Manzoor.

Hi Vasanth,

Thank you for using Aspose products, and welcome to Aspose.Cells support forum.

As per your comments, you have a Workbook object with a huge matrix [30000 x 60] therefore you will require plenty of memory (RAM) to write such Workbook on the disk. We would suggest you to give our latest version of Aspose.Cells for .NET 8.0.0 a try on your end as we have improved the memory utilization in this release. Moreover, we have introduced Memory Optimization Settings that can be used to increase the overall memory performance.

Please feel free to write back in case you face any difficulty or have more questions for us.

Thanks for your valuable response. I tried with latest version of Aspose.Cells for .NET 8.0.0 , still I am facing the same isuue “out of memory exception”. My Datatable contains 300000 records with 60 or more columns. This object I am saving to xlsx format with Worksheet.Cells.ImportDataTable()method.

Hi again,

Sorry to know that the latest build didn’t help.

Please modify your exiting code as outlined below while using the latest version of Aspose.Cells for .NET 8.0.0.


//Instantiate a new Workbook
Workbook book = new Workbook(FileFormatType.Xlsx);
//Note: This setting will not take effect for the existing worksheets that are created before setting the memory preferences
//Set the memory preferences
book.Settings.MemorySetting = MemorySetting.MemoryPreference;
//Note: The memory settings also would not work for the default sheet i.e., “Sheet1” etc. automatically created by the Workbook
//Get cells of the newly created Worksheet “Sheet2”
Cells cells = book.Worksheets.Add(“Sheet2”).Cells;
//Import DataTable using Cells.ImportDataTable method

In case the problem persists, please more details of your environment such as Operating System version, Operating System Architecture (32bit/64bit), Service Pack, Target Framework version, RAM etc. We need this information to replicate the environment on our end so we could further troubleshoot the issue.

Thanks for this code. This is working now. At the end of the code I forcefully release the memory ( GC.Collect()).

Hi Vasanth,

Good to know you are up and running again. Please feel free to write back in case you need our further assistance.