Aspose Cell - How to enable editing

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,


We cannot evaluate your issue unless we have your template Excel file. Please provide your template Excel file containing the chart here, we will check your issue soon.

Thank you.

Hi,
I’ve attached the template.

Regards,

Roi

Hi,


Thanks for the template file.

Well, your chart is based on the PivotTable. You provided us the template file, we would need your Excel file with filled data or filled Pivot Table report. Kindly provide us your template file with PivotTable filled with your data, so we could evaluate your issue on our end using your sample code snippet. If you are dynamically filling the template file with data, kindly provide us the relevant code snippet. By the way, you should try to use the following lines of code before rendering the chart to image as your chart is based on the PivotTable report’s data if it makes any difference.
e.g
Sample code:
//…
PivotTable pt = sheet.getPivotTables().get(0);
pt.refreshData();
pt .calculateData();


Thank you.