Currently, I use the source pptx, add the new slide to it, hide the first slide and save it to a new location.
First I load the existing slide:
- Code: Select all
SlidePart slide = (SlidePart)presentationMLPackage.getParts().get(
new PartName("/ppt/slides/slide3.xml") );
Then I load the existing chart:
- Code: Select all
Chart chart1Part = (Chart)presentationMLPackage.getParts().get(
new PartName("/ppt/charts/chart1.xml"));
Create a clone of the existing slide
- Code: Select all
Sld sld = XmlUtils.deepCopy(slide.getJaxbElement(), slide.getJAXBContext());
PresentationMLPackage.createSlidePart(pp, layoutPart, new PartName(slideToAddPartName));
targetSlide.setJaxbElement(sld);
Then add the chart part
- Code: Select all
targetSlide.addTargetPart(chart1Part);
I have tried the above with AddPartBehaviour.RENAME_IF_NAME_EXISTS also, but that does not affect anything
The issue is strange. When I open the output file, I see dialog box which is attached. When I click OK, I can see the chart no problem, but I cannot get rid of this dialog box.
Note, also that there are other slides in my ppt but this issue crops up only for slides with charts.
Any help would be appreciated!!