Cells and Words + flushing partialy generated file to disk

Hi,

I am testing currently Cells and I have to generate big xslx file (million rows) and I see that the whole file is generated in memory and then saved (flushed) to disk.

My question is - is it possible to partially generate file (xlsx, xls) and then flush to disk (similar like StreamWriter Flush() method).

Maybe you can give some other hints how to not allocate so huge memory...


Regards,

Tomasz Janicki

Hi,

Well, in recent versions, we have supported cached file in saving XLS files, so you may try it if it is useful for you.
Sample code:
SaveOptions saveOptions = new Aspose.Cells.XlsSaveOptions(SaveFormat.Excel97To2003);
saveOptions.CachedFileFolder = stringFolder;
workbook.Save(“e:\test\output.xls”, saveOptions);


I have also attached the latest version/fix for you.

Thank you.

Hi,

I think that your code is not useful for me - it does not work as I am expecting - the memory usage constantly growing during file generation.

I will try to explain in more details my issue via code bellow:

var wb = new Workbook(FileFormatType.Excel97To2003);
for (var ind = 0; ind < 30; ind++)
{
wb.Worksheets.Add();
var sheet = wb.Worksheets[wb.Worksheets.Count - 1];
for (var i = 0; i < 65536; i++)
{
var cell1 = sheet.Cells[string.Format("A{0}", (i + 2))];
cell1.PutValue(i + 2);
var cell2 = sheet.Cells[string.Format("B{0}", (i + 2))];
cell2.PutValue(i + 4);
}
wb.FlushToDisk(); //no such method, here I want to save to disk and deallocate memory ()
}
wb.Save(@"d:\tmp2\_BigSizeSimple2.xls");

Is in Cells a method which is similar to FlushToDisk which allow to deallocate memory and write this chunk to disk - similarly like in StreamWriter.

When I run above code memory needed for producing this report is about 200 MB. I am concerned about generating on demand files in ASP.NET application.

Regards,

Tomasz Janicki








Hi Tomek,

Thank you very much for the code example and the explanation. We are continuously working on consumption of large amount of memory to be reduced. Currently there is no such method available. This issue has been logged with ID CELLSNET-21150.

We will look into the possibilities of implementing the said functionality in the way you described or into any other way possible. We will update you with the solution as soon as possible.

Thank you for your endurance.

Hi Tomek,

Please try the XlsSaveOptions.CachedFileFolder property to reduce memory.

Code snippet:
Workbook workbook = new Workbook();
XlsSaveOptions saveOptions = new XlsSaveOptions();
saveOptions.CachedFileFolder = @"D:\FileTemp\";
workbook.Save(@"D:\FileTemp\dest.xls",saveOptions);

If the issue persist please feel free to reach us.

Thanks,