Page 1 of 1

How to copy a Chart from another .PPTX file?

PostPosted: Tue Feb 28, 2012 12:20 pm
by insomnion
Hi,

I'm still working on PPTX document copy, and I have troubles with charts.
It works fine when I copy a Chart part, but when I try to add an embedded XLSX object, I see following line in the log:

Code: Select all
org.docx4j.openpackaging.parts.relationships.RelationshipsPart  - True - will delete relationship with target ../embeddings/Microsoft_Office_Excel_Worksheet1.xlsx


It comes right after doing this:
Code: Select all
chartPart.addTargetPart(xlsxPart);


SaveToZipFile throws an Exception:

Code: Select all
org.docx4j.openpackaging.exceptions.Docx4JException: Failed to add parts from relationships
   at org.docx4j.openpackaging.io.SaveToZipFile.addPartsFromRelationships(SaveToZipFile.java:334)
   at org.docx4j.openpackaging.io.SaveToZipFile.save(SaveToZipFile.java:159)
   at org.docx4j.openpackaging.io.SaveToZipFile.save(SaveToZipFile.java:88)
        ...


When I try to add this embedded XLSX object directly to the SlidePart, it doesn't throw any exception, but PowerPoint says that file is corrupted.
However, it is able to recovery, and displays this file correctly, but it's not a solution.

Is there any special processing for Charts or embedded objects?
Any help is appreciated.

Thanks you.
Dmitriy.

Re: How to copy a Chart from another .PPTX file?

PostPosted: Wed Feb 29, 2012 9:02 pm
by jason
Try calling that method with parameter AddPartBehaviour.RENAME_IF_NAME_EXISTS? (You may need to do that for the chart itself)