Hello. Can you please help me.
I need to receive an image of my chart, scaled in 70%. When i saved my chart to image, i have received an image with some noise. How i can fix it?
public void chartTest() throws Exception {
Workbook workbook = new Workbook(“D://chart.xlsx”);
Chart shape = workbook.getWorksheets().get(0).getCharts().get(0);
// Width
int w = (int) (shape.getChartObject().getWidth() * 0.7);
// Height
int h = (int) (shape.getChartObject().getHeight() * 0.7);
File f = new File(“D://out.png”);
try (FileOutputStream out = new FileOutputStream(f)) {
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setImageFormat(ImageFormat.getPng());
int hDPI = ((Double) Math.floor(h/shape.getChartObject().getHeightInch())).intValue();
int wDPI = ((Double) Math.floor(w/shape.getChartObject().getWidthInch())).intValue();
options.setHorizontalResolution(wDPI);
options.setVerticalResolution(hDPI);
shape.toImage(out, options);
}
}