Chart.ToImage result in java.lang.ArrayIndexOutOfBoundsException

Hi,
i run in this problem after call chart.toImage, i have this stack trace:

Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:418)
at java.util.ArrayList.get(ArrayList.java:431)
at com.aspose.cells.zke.a(Unknown Source)
at com.aspose.cells.zke.k(Unknown Source)
at com.aspose.cells.zke.d(Unknown Source)
at com.aspose.cells.zke.a(Unknown Source)
at com.aspose.cells.zke.a(Unknown Source)
at com.aspose.cells.zke.a(Unknown Source)
at com.aspose.cells.Chart.a(Unknown Source)
at com.aspose.cells.Chart.toImage(Unknown Source)
at com.tagetik.cpm.ooxml.aspose.cells.TestChart.main(TestChart.java:21)

i have Aspose.cells 17.9.
here it is the piece of code

public class TestChart {
public static void main(String[] args) throws Exception {
Workbook wk = new Workbook(“test_chart.xlsx”);
Worksheet worksheet = wk.getWorksheets().get(“MAJOR CATS”);
InOutStream inOutStream = new InOutStream();
Chart chart = worksheet.getCharts().get(“Chart1N”);
ImageOrPrintOptions opts = new ImageOrPrintOptions();
opts.setImageFormat(ImageFormat.getPng());
opts.setOnePagePerSheet(true);
opts.setOnlyArea(true);
opts.setHorizontalResolution(220);
opts.setVerticalResolution(220);
chart.toImage(inOutStream, opts);
}
}

I attach also the xml file.
Can you help me to find where the problem is?

test_chart.zip (105.7 KB)

@m4tte,

Thanks for the template file, sample code and stack trace.

After an initial test, I am able to reproduce the issue as you mentioned by using your sample code with your template file. I found the an exception “java.lang.ArrayIndexOutOfBoundsException” on chart.toImage() method. I have logged a ticket with an id “CELLSJAVA-42428” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.

@m4tte,

Please try our latest version/fix for Java:

Your issue should be fixed now.

Let us know your feedback.

The issues you have found earlier (filed as CELLSJAVA-42428) have been fixed in this Aspose.Cells for Java 17.11 update.

Please also check the following document/blog for your reference: