Export Sheet Print Area to EMF image with desired size and resolution

@oraspose,

I did test your scenario/case using the following sample code (as we suggested earlier) with your template XLSX file and you are right. The image is rendered with 96 DPI. We will be looking into it soon.

int desiredResolution = 72;
Workbook wb = new Workbook("f:\\files\\SampleWorkbook.xlsx");
Worksheet sheet = wb.getWorksheets().get(0);

PageSetup pageSetup = sheet.getPageSetup();
pageSetup.setTopMargin(0);
pageSetup.setBottomMargin(0);
pageSetup.setLeftMargin(0);
pageSetup.setRightMargin(0);

String rangeName = "A1:P37";
pageSetup.setPrintArea(rangeName);

ImageOrPrintOptions imgOpt = new ImageOrPrintOptions();
imgOpt.setOnePagePerSheet(true);
imgOpt.setImageType(ImageType.EMF);
imgOpt.setTransparent(true);
imgOpt.setHorizontalResolution(desiredResolution);
imgOpt.setVerticalResolution(desiredResolution);

SheetRender sr = new SheetRender(sheet, imgOpt);
sr.toImage(0, "f:\\files\\output.emf");

output.zip (55.0 KB)

I got the right output EMF image (check the output image) with complete printable area after generating it by the above code segment. I am using latest version of the API (Aspose.Cells for Java v24.1), so you should try it if you are not already using it.

Thanks for trying out. I will try again with the Aspose cells v24.1 from my end.

@oraspose
You are welcome. If you have any questions, please feel free to contact us.

@oraspose

Using the lastest version v24.1, the resolution of output EMF image is the right value 72. Please check the result EMF image generated by @amjad.sahi .

The resolution in “MS Paint” is the device’s DPI, not the resolution of the EMF image. e.g. you can change display setting in Winodows->Settings of your machine. The resolution in “MS Paint” changes for the same EMF image.(96 for 100% display setting, 192 for 200% setting.)

I use “Microsoft Office Picture”, the resolution is 72.
resolution_72.png (27.4 KB)

@peyton.xu Thank you for the details.

@oraspose,

You are welcome.

@oraspose,

This is to inform you that the issue (logged earlier as “CELLSJAVA-45828”) has been resolved. The fix/enhancement will be included in the upcoming release (Aspose.Cells v24.2) that we plan to release in the next week hopefully. You will be notified when the next version is released.

@amjad.sahi Thank you for then notification. Will check this use-case once the 24.02 release is available and confirm if the issue is resolved.

@oraspose
You are welcome. Once Aspose.Cells v24.2 is released, we will notify you promptly.

The issues you have found earlier (filed as CELLSJAVA-45828,CELLSJAVA-45820) have been fixed in Aspose.Cells for Java 24.2.