问题背景:
使用Aspose.Cell.dll(版本为:20.3.0.0)在处理单个Excel文件转换为Html文件时,每次都会出现IIS站点资源占用内存过高的问题,每次都监视到w3wp.exe进程从10MB在1、2s以内瞬间涨到1G以上,然后再降到500MB左右。
内存过高录屏演示
https://imgtu.com/i/fKOMyF
demo下载(内含样例excel)
链接:https://pan.baidu.com/s/1ivXht1AEmqr0JwAWNaGOTA
提取码:qzkx
核心代码:
public static void Handle(string inputFile, string outputFile)
{
HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.Html);
saveOptions.ImageOptions.ImageType = ImageType.Png;
saveOptions.ImageOptions.Transparent = true;
saveOptions.ImageOptions.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
saveOptions.ImageOptions.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
saveOptions.ExportGridLines = true;
saveOptions.ExportImagesAsBase64 = true;
saveOptions.ExportWorksheetCSSSeparately = false;
saveOptions.ExportHiddenWorksheet = false;
using (var fileStream = new FileStream(inputFile, FileMode.Open, FileAccess.Read, FileShare.Read))
{
using (Workbook excel = new Aspose.Cells.Workbook(fileStream))
{
using (var tempExcel = CopyVisibleSheet(excel))
{
PreProcess(tempExcel);
tempExcel.Save(outputFile, saveOptions);
}
}
}
}
是否有什么方案或新版本的Aspose.Cell可解决内存飙升过高的问题?