Well, you should use EMF image format, it will give you maximum quality, you may try to change your code segment a bit to set the image format and get the resultant image in EMF file format.
Please execute the following piece of code against your previously shared sample spreadsheet and the latest version of Aspose.Cells for Java 8.3.2.3. Attached are the results from my end.
Java
Workbook workbook = new Workbook(“D:/temp/Book.xlsx”);
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportActiveWorksheetOnly(true); options.setHiddenColDisplayType(HtmlHiddenColDisplayType.HIDDEN);
options.setHiddenRowDisplayType(HtmlHiddenRowDisplayType.HIDDEN); workbook.save(“D:/SavedWithNoRenderingHints.html”, options);
ImageOrPrintOptions op = new ImageOrPrintOptions();
op.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
op.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
op.setImageFormat(ImageFormat.getPng());
SheetRender render = new SheetRender(workbook.getWorksheets().get(0), op);
render.toImage(0, “D:/SavedWithImageOrPrintOptions.png”);
SheetRender render2 = new SheetRender(workbook.getWorksheets().get(0), options.getImageOptions());
render2.toImage(0, “D:/SavedWithHtmlSaveOptions.png”);
By reviewing the results you will notice that the image quality in the HTML files generated with and without specifying the rendering hints are different. The image in the SavedWithRenderingHints.html is better in quality and smoothness, means rendering hints are working for HtmlSaveOptions.
Please also compare the results SavedWithImageOrPrintOptions.png and SavedWithHtmlSaveOptions.png, you will find the result saved using the ImageOrPrintOptions instance directly is more clear as compared to HtmlSaveOptions.getImageOrPrintOptions. However, both mentioned images do not have Rendering Hints applied so we need to investigate the matter from the perspective of SheetRender class. Please confirm your exact requirement for this scenario.
Please compare SavedWithImageOrPrintOptions.png and SavedWithRenderingHints_files\chart_Sheet1_0.png
The pie is difference. You can see pie in SavedWithImageOrPrintOptions.png is not anti-aliasing while SavedWithRenderingHints_files\chart_Sheet1_0.png is anit-aliasing
We have logged a ticket (CELLSJAVA-41208) in our issue tracking system to investigate the matter of anti aliasing not being applied while using the SheetRender to convert worksheets to image. Please check the following piece of code for reference.
Java
ImageOrPrintOptions op = new ImageOrPrintOptions();
op.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
op.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
op.setImageFormat(ImageFormat.getPng());
SheetRender render = new SheetRender(workbook.getWorksheets().get(0), op);
render.toImage(0, “D:/SavedWithImageOrPrintOptions.png”);
Please spare us little time to isolate the problem cause, and to provide the fix at earliest possible. In the meanwhile, we will keep you posted with updates in this regard.