i have code as shown below opening an excel files and generating a thumbnail from specified sheet. if i use it to open up the attached xlsx file (hcr calculator 01_29) , when the new Workbook line is called, if I watch cpu usage, it spikes to 35-40% and it take a few seconds to open. I would not expect this behavior from a 5meg file. This seems like an issue to me, because we use this under the context of a service, but if one call is generating this much time and cpu overhead, that is not very scalable.
I also attached a smaller file (benefits statemet with chart..), which takes subsecond as a comparison. its only 1.7 meg, but still nowhere near the time and cpu usage to open it up.
ideas?
public Image CreateThumbnail(byte[] file, int worksheetNumber, int resolution) { int adjustedWorksheetNumber = worksheetNumber - 1; Workbook book = new Workbook(new MemoryStream(file)); Worksheet sheet = book.Worksheets[adjustedWorksheetNumber]; ImageOrPrintOptions options = new ImageOrPrintOptions(); options.ImageFormat = ImageFormat.Png; options.HorizontalResolution = resolution; options.VerticalResolution = resolution; sheet.PageSetup.FitToPagesTall = 1; sheet.PageSetup.FitToPagesWide = 1;
var render = new SheetRender(sheet, options);
//render.PageCount = 1;
return render.ToImage(0);
}</p>