Hello,
i have an excel with data and a chart.
i would like to export the chart into an image.
i managed to do that but the problem is that the image of the chart is empty…
it seems that i need to do something like enable editing (like when opening the file in Microsoft Excel) in my code.
here is what i do:
Workbook book = new Workbook(“C:\My_Excel_file.xlsx”);
book.calculateFormula(true);
// taking the sheet no.1 that has the chart
Worksheet sheet = book.getWorksheets().get(1);
Chart chart = sheet.getCharts().get(0);
//Create an object for ImageOptions
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
//Set the image type
imgOptions.setAllColumnsInOnePagePerSheet(true);
imgOptions.setImageFormat(ImageFormat.getPng());
chart.toImage(“C:\chartImage.png”, imgOptions);
Can you please guide me to solution?
Thanks,
Roi
Hi Roi,
Thank you for considering Aspose products.
Please call Chart.calculate() method before Chart.toImage() method. Hopefully this will resolve the empty chart image problem. In case the problem persists, please provide us your sample spreadsheet so that we could review it before providing further assistance in this regard.
Hi,
Thanks for the quick response.
the image is still empty after adding the chart.calculate()
i need to remove the protection from the excel file.
is there a way to do that?
Regards,
Roi
Hi,
Hi,
I’ve attached the template.
Regards,
Roi
Hi,