Please see the demo atthachment, i am building a preview online website with Aspose.Cell 24.1.0, sometimes there is a memory leak problem with a small excel file(file also in demo attachment).
So could you provide a demo project to help solve the following problems:
how to dispose the memory(it could not dispose even call GC.Collect();).
how to interrupt the request, and release the server memory when excute over 3 second.
when there is multi sheets in excel file, how to just load one active sheet and others sheets’s name, then not load other sheet until user click that sheet name?
Tks. AsposeDemo.7z (952.2 KB)
I did test your scenario/case using your sample project with Aspose.Cells for .NET v24.7 (please get it and try it: Releases | NuGet). It works fine and I do not see any error or find any significant memory leakage. But, surely, the browser will consume more memory to display the output HTML (having so many records in it). Do you mean the memory of the browser in the which the rendered (output) HTML is shown is increased?
Thanks for you reply.
The server memory will increase to maybe 1GB even when the source file is just 4MB+ when call the document.Save function, and could not release the memory for a long time.
Not memory in client browser memory.
Due to it’s a preview online website and many other user may visit the same file or same problem , Hope it can decrease the server memory as soon as posible and protect the server memory.
Good to know that the suggested version (Aspose.Cells for .NET v24.7) works well for your needs. Please feel free to write back to us if you have further queries or comments.
Thanks for your reply. it’s great with v24.7, i will upgrade to it.
Please help to continue paying attention to these issues and hope to find a solution
@davidxiao2008
1, how to dispose the memory(it could not dispose even call GC.Collect();).
We have created an ticket CELLSNET-56313 for this issue.
2, how to interrupt the request, and release the server memory when excute over 3 second.
3, when there is multi sheets in excel file, how to just load one active sheet and others sheets’s name, then not load other sheet until user click that sheet name?
Thanks for reply.
for point 1, is there a solution can gc by Aspose.Cell v24.7?
for point 2 & 3, please provide a sample netcore project files with ActionResult in MVC, thank you.
1). We have already logged a ticket with an id “CELLSNET-56313” for the issue. Let us evaluate it in details and then we will be able to either provide a solution or a fixed version.
2) & 3). Please refer to the examples in the suggested documents and then write your own code for your requirements.
hi simon,
for point 3, there is my test code with a demo file( active sheet is [sheetddd], hide sheet is [sheetccc], i got 2 questions need your help.
how can point out the active sheet when CustomLoad, so it can show the content when save as html format.
Can i modify the js function fnSetActiveSheet, so can redirect to another sheet or load another sheet content by ajax when user click. demo2.7z (37.6 KB)
@davidxiao2008
You can use the Workbook.Worksheets.ActiveSheetIndex or Workbook.Worksheets.ActiveSheetName attribute to specify the current active worksheet.
There not exists Workbook.Worksheets.ActiveSheetIndex before load excel file. So i could not use it in CustomLoad
// Load the workbook with the spcified worksheet only.
LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
loadOptions.LoadFilter = new CustomLoad();
Here is another question need help.
Could you give a suggestion how to toggle another sheet and fill with content, when save excel to html format just like my demo : AsposeDemo.7z
@davidxiao2008
You can set up Worksheets.ActiveSheetIndex equals the index of the worksheet that needs to be exported and sets the HtmlSaveOptions.ExportActiveWorksheetOnly is set to true to export only the current active worksheet.
Sorry, there is my operation process :
step 1, save excel file as html format and only show active sheet content and other sheets struct with CustomLoadFilter.
step 2, user click other sheet name to toggle sheet, but get a empty sheet content.
So my question is how to fill the other sheet content in step 2.
Please note, when you only load a specific sheet, other sheets would be discarded and only the name/structures would be retrieved. For your case, you should not load a specific sheet only and instead load all the sheets so that when you click on other sheet tabs, the data would be displayed correctly in the browser.
Moreover, we have already logged a ticket (“CELLSNET-56313”) to address the issue of disposing resources when exporting HTML files, so please wait until the fixed version is published. Hopefully, after using the fixed version, there would be no memory leakage issue.
class CustomLoad1 : LoadFilter
{
public override void StartSheet(Worksheet sheet)
{
if (sheet.Name== “selected”)
{
// Load everything from worksheet "Sheet2"
this.LoadDataFilterOptions = LoadDataFilterOptions.All;
}
else
{
// Load nothing
this.LoadDataFilterOptions = LoadDataFilterOptions.Structure;
}
}
}
After loading the file, then set this worksheet as active and export it to html.
Then replace the old empty html of this worksheet.
BTW after checking convert “demo.xls” to html, we find the main performance issue is converting to html works slow, so you can simply load the file once, then export to html one worksheet by one.