Page 1 of 1

Pptx chart manupulation in EmbeddedPackagePart

PostPosted: Wed Feb 01, 2012 2:31 pm
by ikola
Hi ,

I am trying to manipulate the chart data inside the embeded excel file of the pptx.

I was able to read and replace the excel file inside the PPTX but after saving the excel has the latest file with values but the chart is not getting rendered.

When I open the new saved file and click on edit data for chart then it shows the chart with new values.

Can some one shed some light and help.

Here is code snippet :

PresentationMLPackage pMLPackage =
(PresentationMLPackage)OpcPackage.load(new java.io.File(inputfilepath));

SlidePart slide = (SlidePart)pMLPackage.getParts().get(new PartName("/ppt/slides/slide1.xml") );

EmbeddedPackagePart embeded = new EmbeddedPackagePart(new PartName("/ppt/embeddings/Microsoft_Office_Excel_Worksheet1.xlsx"));

embeded.setBinaryData(getBytesFromFile(new File("C:/Sprint1-Templates/embeded.xlsx")));

pMLPackage.getParts().getParts().put(new PartName("/ppt/embeddings/Microsoft_Office_Excel_Worksheet1.xlsx"), embeded);
pMLPackage.save(new File("C:/Sprint1-Templates/pptx_chart_outsave.pptx"));

Thanks,
ik

Re: Pptx chart manupulation in EmbeddedPackagePart

PostPosted: Wed Feb 01, 2012 7:14 pm
by jason
The chart is being rendered on the basis of the values which are present in your /ppt/charts/chart1.xml (whatever it is called).

You can alter those values yourself, and see this reflected immediately.

Is it feasible for you to programmatically alter chart1.xml (eg using pptx4j) ?

Re: Pptx chart manupulation in EmbeddedPackagePart

PostPosted: Thu Feb 02, 2012 9:08 am
by ikola
Hi Jason,

Thank you for the quick response and really cool OOXML java support.

Yes it is possible I can use that approach .. but do i need to update both chart. xml and embedded xlsx?

I did not find any sample for charts .. is there any sample for PPTX chart manipulation ?

A sample or code snippet with steps will be helpful.

Regards,
Isaac

Re: Pptx chart manupulation in EmbeddedPackagePart

PostPosted: Thu Feb 02, 2012 8:37 pm
by jason
Editing chart.xml is enough to cause Word to display an updated chart. To edit a org.docx4j.openpackaging.parts.DrawingML.Chart part, you start with getJaxbElement() in the usual way.

However, unless you also updated the XLSX, a user double clicking to edit would then see the old figures in Excel.

Re: Pptx chart manupulation in EmbeddedPackagePart

PostPosted: Fri Feb 03, 2012 8:30 pm
by ikola
Thank you Jason , that works.. Is there a way I can disable the user's edit options on the graph?
It may be nice to have sync between embedded data and jaxb objects....

Cheers...
IK

Re: Pptx chart manupulation in EmbeddedPackagePart

PostPosted: Wed Feb 15, 2012 11:06 am
by awestwell
Hey Guys

Do you have a working sample I am basically wanting to do the sample thing. Figured I would as first. I want to edit the embedded excel sheet for a chart

Re: Pptx chart manupulation in EmbeddedPackagePart

PostPosted: Wed Feb 15, 2012 1:33 pm
by ikola
Embedded excel option will not auto refresh the PPTX.. you have to use the JAXB objects to manipulate and render the graphs.