We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Chart to Image is machine dependent

Hi,


I am using aspose cells for java 7.2.2.1. I have an issue where in the following code runs just fine in in collegue’s machine but not mine. Both of us use the same aspose jars/license, same os, same os type. Can you please let me know how can I probably get rid of this? Attached the file that I am using.

Below is my machine details :
Aspose Cells version - 7.2.2.1
Jdk - 1.6
Os: Win 7 64 bit
Code:
@Test
public void testFromFile() {
try {
Workbook workbook = new Workbook(“C:/Pravat/Test/myFile.xlsx”);
Worksheet worksheet = workbook.getWorksheets().get(“Report”);
int count = worksheet.getCharts().getCount();
Chart chart = worksheet.getCharts().get(0);

ImageOrPrintOptions imgOpts = new ImageOrPrintOptions();
imgOpts.setImageFormat(ImageFormat.getJpeg());

//Save the chart image file.
chart.toImage(new FileOutputStream(“C:\Pravat\Test\MyChartImage.jpeg”), imgOpts);
} catch(Exception e) {
e.printStackTrace();
}
}
Exceprion that I get is :
java.lang.ArrayIndexOutOfBoundsException: 0
at sun.font.ExtendedTextSourceLabel.createCharinfo(Unknown Source)
at sun.font.ExtendedTextSourceLabel.getCharinfo(Unknown Source)
at sun.font.ExtendedTextSourceLabel.getLineBreakIndex(Unknown Source)
at java.awt.font.TextMeasurer.calcLineBreak(Unknown Source)
at java.awt.font.TextMeasurer.getLineBreakIndex(Unknown Source)
at com.aspose.cells.b.a.b.d.a.c.n(Unknown Source)
at com.aspose.cells.b.a.b.d.a.c.k(Unknown Source)
at com.aspose.cells.b.a.b.i.a(Unknown Source)
at com.aspose.cells.b.a.b.i.a(Unknown Source)
at com.aspose.cells.zc.a(Unknown Source)
at com.aspose.cells.mK.b(Unknown Source)
at com.aspose.cells.mK.b(Unknown Source)
at com.aspose.cells.mK.a(Unknown Source)
at com.aspose.cells.bQ.a(Unknown Source)
at com.aspose.cells.bQ.b(Unknown Source)
at com.aspose.cells.cD.aj(Unknown Source)
at com.aspose.cells.B.t(Unknown Source)
at com.aspose.cells.B.p(Unknown Source)
at com.aspose.cells.cG.a(Unknown Source)
at com.aspose.cells.Chart.toImage(Unknown Source)

Hi,


Thanks for providing us the template file and sharing the sample code.

I observed the issue as you mentioned. I got the similar exception as you pointed out by using your sample code with your file.

Sample code:

try {
Workbook workbook = new Workbook(“myFile.xlsx”);
Worksheet worksheet = workbook.getWorksheets().get(“Report”);
int count = worksheet.getCharts().getCount();
System.out.println(count); //1 - OK
Chart chart = worksheet.getCharts().get(0);

ImageOrPrintOptions imgOpts = new ImageOrPrintOptions();
imgOpts.setImageFormat(ImageFormat.getJpeg());

//Save the chart image file.
chart.toImage(new FileOutputStream(outMyChartImage.jpeg”), imgOpts);
} catch(Exception e) {
e.printStackTrace();
}
}

I am using v7.5.0.3 (latest fix) with JDK version 1.7.0_21. I have logged a ticket with an id “CELLSJAVA-40558” for your issue. We will look into your issue soon.

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

Thank you.

The issues you have found earlier (filed as CELLSJAVA-40558) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.