single_day 2017-11-29 17:00 采纳率: 0%
浏览 1385
已结题

C#winform资源释放问题

C#在调用Aspose.Cells.dll把Excel表格生成图片时内存占用率会越来越高是什么问题?

 Workbook book = new Workbook(Application.StartupPath + @"\Config\excel.xlsx");
            Worksheet sheet = book.Worksheets[0];

            sheet.PageSetup.LeftMargin = 0;
            sheet.PageSetup.RightMargin = 0;
            sheet.PageSetup.BottomMargin = 0;
            sheet.PageSetup.TopMargin = 0;

            ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
            imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Bmp;

            imgOptions.OnePagePerSheet = true;
            imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;

            SheetRender sr = new SheetRender(sheet, imgOptions);
            sr.ToImage(0, Application.StartupPath + @"\Config\Excel.bmp");

这段代码是放在timer里面定时循环执行的!

  • 写回答

10条回答 默认 最新

  • threenewbee 2017-11-29 17:01
    关注

    不排除aspose有内存泄漏,用using把Workbook、SheetRender都包括进来,或者用dispose方法释放下。

    评论

报告相同问题?