"Creating Excel Chart and Embedding it in Presentation (PPTX) as OLE Object" Example does not work

Hi,

I am trying to follow the example found at the URL below:

However, I am getting java.lang.ArrayIndexOutOfBoundsException: 9 on the line “pres.write”. Can you please provide a working example in Java on how to create a Powerpoint presentation with embedded Excel chart in 2007 format?

Thanks.

Hi Pimco,


I have worked with the pointed sample code and have generated a netbeans project for your convenience. I have not been able to reproduce the issue. I have used Aspose.Slides for Java 6.9.1 and Aspose.Cells for Java 7.3.0. For your kind reference, I have also share the generated presentation.

Please share, if I may help you further in this regard.

Many Thanks,

Hi Mudassir,

I ran the exact code you provided, using aspose.slides-6.9.1 and aspose.cells-7.4.0. But I got this exception:

java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException
at com.aspose.slides.SlideEx.do(Unknown Source)
at com.aspose.slides.PresentationEx.else(Unknown Source)
at com.aspose.slides.PresentationEx.do(Unknown Source)
at com.aspose.slides.PresentationEx.do(Unknown Source)
at com.aspose.slides.PresentationEx.do(Unknown Source)
at com.aspose.slides.PresentationEx.write(Unknown Source)
at com.aspose.slides.PresentationEx.write(Unknown Source)
at sampleole.SampleOle.Run(SampleOle.java:50)
at sampleole.SampleOle.main(SampleOle.java:129)
Caused by: java.lang.ArrayIndexOutOfBoundsException

Thanks,
Roy

Do I need a paid license to run this? I tried without any license (your
code), and with a trial license, both threw the
ArrayIndexOutOfBoundsException. Attached java file is the code that I used with the
trial license.

Hi Mudassir,

I managed to get more stack trace information by using the debugger in IDE. Here it is,

java.lang.ArrayIndexOutOfBoundsException: 9
at com.aspose.slides.c.b.g.do(Unknown Source)
at com.aspose.slides.c.b.g.do(Unknown Source)
at com.aspose.slides.c.a.x.case(Unknown Source)
at com.aspose.slides.c.a.k.H.if(Unknown Source)
at com.aspose.slides.c.a.k.H.if(Unknown Source)
at com.aspose.slides.c.a.k.H.if(Unknown Source)
at com.aspose.slides.c.a.k.r.for(Unknown Source)
at com.aspose.slides.a.l.C.if(Unknown Source)
at com.aspose.slides.a.l.C.try(Unknown Source)
at com.aspose.slides.a.l.C.do(Unknown Source)
at com.aspose.slides.a.l.k.do(Unknown Source)
at com.aspose.slides.a.l.k.(Unknown Source)
at com.aspose.slides.a.l.h.case(Unknown Source)
at com.aspose.slides.a.l.h.try(Unknown Source)
at com.aspose.slides.a.l.h.do(Unknown Source)
at com.aspose.slides.a.l.j.do(Unknown Source)
at com.aspose.slides.a.l.j.do(Unknown Source)
at com.aspose.slides.a.l.j.do(Unknown Source)
at com.aspose.slides.oi.(Unknown Source)
at com.aspose.slides.Kx.int(Unknown Source)
at com.aspose.slides.Kx.final(Unknown Source)
at com.aspose.slides.cD.do(Unknown Source)
at com.aspose.slides.JO.do(Unknown Source)
at com.aspose.slides.JO.do(Unknown Source)
at com.aspose.slides.JO.do(Unknown Source)
at com.aspose.slides.JO.do(Unknown Source)
at com.aspose.slides.JO.(Unknown Source)
at com.aspose.slides.TextFrameEx.do(Unknown Source)
at com.aspose.slides.AutoShapeEx.do(Unknown Source)
at com.aspose.slides.AutoShapeEx.case(Unknown Source)
at com.aspose.slides.AutoShapeEx.do(Unknown Source)
at com.aspose.slides.ShapesEx.do(Unknown Source)
at com.aspose.slides.GroupShapeEx.do(Unknown Source)
at com.aspose.slides.BaseSlideEx.do(Unknown Source)
at com.aspose.slides.MasterSlideEx.do(Unknown Source)
at com.aspose.slides.PresentationEx.do(Unknown Source)
at com.aspose.slides.PresentationEx.do(Unknown Source)
at com.aspose.slides.PresentationEx.do(Unknown Source)
at com.aspose.slides.PresentationEx.write(Unknown Source)
at com.aspose.slides.PresentationEx.write(Unknown Source)
at sampleole.SampleOle.Run(SampleOle.java:50)
at sampleole.SampleOle.main(SampleOle.java:129)

Can you please take a look at it. Thanks.

Hi,


I like to share that there is no issue in the code as I have tested with latest versions of Aspose.Slides for Java and cells on my end. Can you please comment the license setting lines on your end and test the things. Secondly, can you please also share that which versions of Aspose.Slides and Cells you are using on your end. Please also share the environment and JDK details on your end. Please also highlight the point in the code section where by you are getting the issue. As, I shared with you earlier that I have tested on my end without license and and generated presentation shows the watermark for this. IMO, license is not an issue.

Many Thanks,

I am using JDK 1.6.0_33, Aspose.Slides-6.9.1, Aspose.Cells-7.4.0. I tried your code (without license, and only removed the path for the generated pptx file D:\Aspose Data\), and got this error:

c:\temp\aspose-test>javac -classpath “lib\aspose.slides-6.9.1.jar;lib\aspose-cells-7.4.0.jar” -d out src\sampl
eole\SampleOle.java
Note: src\sampleole\SampleOle.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

c:\temp\aspose-test>java -classpath “lib\aspose.slides-6.9.1.jar;lib\aspose-cells-7.4.0.jar;out” sampleole.Sam
pleOle
java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException
at com.aspose.slides.SlideEx.do(Unknown Source)
at com.aspose.slides.PresentationEx.else(Unknown Source)
at com.aspose.slides.PresentationEx.do(Unknown Source)
at com.aspose.slides.PresentationEx.do(Unknown Source)
at com.aspose.slides.PresentationEx.do(Unknown Source)
at com.aspose.slides.PresentationEx.write(Unknown Source)
at com.aspose.slides.PresentationEx.write(Unknown Source)
at sampleole.SampleOle.Run(SampleOle.java:50)
at sampleole.SampleOle.main(SampleOle.java:129)
Caused by: java.lang.ArrayIndexOutOfBoundsException

c:\temp\aspose-test>

I attached a zip file of my test folder, including the source, compiled class file, and the screen shot for the error, including the command I used.

Hi,


I have used the command and exactly same sample shared by you on my end with x86 JDK_1.6.0_27 and x64 JDK_1.6_31. For, both, I am unable to reproduce any issue on my end. For your kind reference, I have also attached the commands used along with image highlighting the successful execution. I would suggest you to please try using the shared JDK versions if possible on your end as I dont’t fell JDK_1.6_33 may have any issue. I am using Windows 7 x64 on my end.

I would also suggest you to please try using a very simple API method, like creating an empty presentation. Can you please also give a try to some other machine as well.

Many Thanks,

I tried on a different computer and it worked. So it is some environmental problem on my computer, I just don’t know what it is. Thanks for your help.

Hi,


That is great that the things worked on your end. Please share, if I may help you further in future.

Many Thanks,

There is another issue. I am trying to embed an Excel 2007 format chart as opposed to a 2003 format chart. I only made a few slight changes to the sample program you provided. When I opened the generated powerpoint file, the chart on the slide appears to be in Excel 2003 format. Yet when I open the chart OLE object, it looks like the Excel 2007 format correctly. I also outputted the excel file as output.xlsx on the file system, and the chart in it looks correct. But for some reason, the chart embedded in the powerpoint is in the old 2003 format. I attached the program file, and the generated pptx and xlsx files.

Hi,


I have observed the requirements shared. Actually, this is not an issue as the default format before saving the excel sheet to file or stream is XLS. You are actually getting the chart image before saving. In order to counter this effect, you need to first save the excel file and then generate the chart image. This will resolve the issue for you. I have attached the modified java file along with generated presentation for your convenience.

Many Thanks,

OK. Thank you for your help.