Sheet to image takes too long

Hi,

I am using Aspose.cells v8.5.2

Using the following code I am converting the first sheet to image that takes too long, on an average 6-7s
private static void tableToImage() throws Exception {
Workbook workbook = new Workbook(“D:\temp\Book1.xlsx”);
workbook.save(“D:\temp\Book1.xlsx”, SaveFormat.XLSX);
com.aspose.cells.Worksheet sheet = workbook.getWorksheets().get(0);
sheet.getPageSetup().setTopMargin(0);
sheet.getPageSetup().setBottomMargin(0);
sheet.getPageSetup().setRightMargin(0);
sheet.getPageSetup().setLeftMargin(0);
ImageOrPrintOptions imageOrPrintOptions = new ImageOrPrintOptions();
imageOrPrintOptions.setHorizontalResolution(600);
imageOrPrintOptions.setVerticalResolution(600);
imageOrPrintOptions.setOnePagePerSheet(true);
imageOrPrintOptions.setOnlyArea(true);
imageOrPrintOptions.setImageFormat(ImageFormat.getPng());
SheetRender sr = new SheetRender(sheet, imageOrPrintOptions);
long st = System.currentTimeMillis();
sr.toImage(0, “D:\temp\out.png”);
long tt = System.currentTimeMillis()-st;
System.out.println(tt +“ms”);
}

Can you please look into this performance issue.

Thanks,
Jaspreet.


Hi,


Thanks for the template file and sample code:

After an initial test, I observed the issue as you mentioned. I found Sheet to image takes 5-6 seconds to render image file on my end. Although it looks to me normal as you are setting horizontal and vertical resolutions with specifying one page per sheet and print only data area options on, so it might take a little more time. I used the following sample code with your template file:
e.g
Sample code:

Workbook workbook = new Workbook(“Book1.xlsx”);
workbook.save(“out1Book1.xlsx”, SaveFormat.XLSX);
com.aspose.cells.Worksheet sheet = workbook.getWorksheets().get(0);
sheet.getPageSetup().setTopMargin(0);
sheet.getPageSetup().setBottomMargin(0);
sheet.getPageSetup().setRightMargin(0);
sheet.getPageSetup().setLeftMargin(0);
ImageOrPrintOptions imageOrPrintOptions = new ImageOrPrintOptions();
imageOrPrintOptions.setHorizontalResolution(600);
imageOrPrintOptions.setVerticalResolution(600);
imageOrPrintOptions.setOnePagePerSheet(true);
imageOrPrintOptions.setOnlyArea(true);
imageOrPrintOptions.setImageFormat(ImageFormat.getPng());
SheetRender sr = new SheetRender(sheet, imageOrPrintOptions);
long st = System.currentTimeMillis();
sr.toImage(0, “f:\files\out1.png”);
long tt = System.currentTimeMillis()-st;
System.out.println(tt +“ms”);

I have logged a ticket with an id “CELLSJAVA-41477” for your issue. Our product team will investigate if we could improve the rendering time further or suggest you more refined way to get better performance.

Once we have any update on it, we will let you know here.

Thank you.

Hi,

Thanks for using Aspose.Cells.

Please try to set lower resolution e.g.


imageOrPrintOptions.setHorizontalResolution(220);
imageOrPrintOptions.setVerticalResolution(220);

It only cost about 1.5s.