- Code: Select all
WordprocessingMLPackage wordprocessingMLPackage = Docx4J.load(new File(System.getProperty("user.dir") + "/uploads/chartCopy.docx"));
Relationship rel = relationshipsPart.getRelationshipByType(Namespaces.SPREADSHEETML_CHART);
Part part = relationshipsPart.getPart(rel);
System.out.println(part.getPartName().getName() );
wordprocessingMLPackage.getMainDocumentPart().addTargetPart(part, RelationshipsPart.AddPartBehaviour.RENAME_IF_NAME_EXISTS);
wordprocessingMLPackage.save(new File(System.getProperty("user.dir") + "/uploads/chartCopyNew.docx"));
However, it does not work either and here is the wrong info:
org.docx4j.openpackaging.exceptions.Docx4JException: Error marshalling JaxbXmlPart /word/charts/chart1.xml
at org.docx4j.openpackaging.io3.stores.ZipPartStore.saveJaxbXmlPart(ZipPartStore.java:346)
at org.docx4j.openpackaging.io3.Save.saveRawXmlPart(Save.java:289)
at org.docx4j.openpackaging.io3.Save.savePart(Save.java:435)
at org.docx4j.openpackaging.io3.Save.addPartsFromRelationships(Save.java:398)
at ...