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

Free Support Forum - aspose.com

Large File creation with styling memory ussage


My application creates exports to excel with styling and chanrts. Sometimes the data can be large amounts which forces a small server out of memory. I read some posts related to styling ussage and changed how the styling works, but the size of the memory stream did not change.

Is there a way to write to a temp file instead of using the memory until the file is completed?

Thank you


Well, our several developers do use Aspose.Cells in their server environment to create large / huge workbooks and manipulate data without much difficulty. Aspose.Cells is a pure .Net component and we totally rely on .NET Garbage Collector(GC) to release memory. GC won't release memory when you set the objects to nothing. It only releases memory when it thinks it's appropriate, Also, in a web asp.net application, memory collection is not only handle by GC, but also by asp.net process.

If you are implementing huge data (with formatting styles or other objects etc.) into worksheets, you should have sufficient memory for the task. The process would certainly consume large amount of memory. The resultant file would also of huge size.

To minimize memory usage and optimize performance you may try a few things (below) if it can be implemented for your scenario:

1. For Aspose.Cells, memory can be extensively consumed for separately set each cell's formattings, creating / implementing too many conditional formattings etc....To resolve such issues, you may optimize your code and create reusable style object(s) based on common formattings related to cells and set these style object(s) to the cells in a worksheet.

2. If you are using large binary object, you might avoid too many large objects in one file.

3. You may populate data first by row then by column, it will also improve the performance. For example, put data in sequence of A1, B1, A2, B2 will be faster than A1, A2, B1, B2. If there are many cells in a worksheet, this tip can make the program much faster and save memory.

4. If you are using DataSet object to fill huge data, you may try using DataReader object instead, it consumes less memory.

5. Try to split you data and objects into multiple worksheets instead of a single big worksheet. Preferably, you can split it to create multiple workbooks.

If the problem persists, Could you please create test project and post us here, so that may check your issue soon.

Thank you.

I am saving rows. I have tried applying styles differently as you suggest in a different post. The size of the stream did not change and also my number formating was removed.

The workbook I create contains multiple spreadsheets. If I save the spreadsheets separatelly, then how would I be able to attach them together in the end.

Thank you


Well, we also suggest you to use Cell.GetStyle and Cell.SetStyle methods instead of using Cell.Style attributes to format a cell as it will save large amount of memory for your task: http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/evaluating-cell-getstyle-setstyle-methods-against-cell-style-property.html

If this does not help, we appreciate if you could create a test project and post us here to reproduce the issue, we will check it soon.

Thank you.