How to duplicate a slide containing a chart using apache POI?
<p>Dear all,</p>

<p>I'm working with Apache POI and I would like to duplicate a slide containing several charts from code.</p>

<p>The code below (inspired by <a href="https://poi.apache.org/slideshow/xslf-cookbook.html#Merge" rel="nofollow">https://poi.apache.org/slideshow/xslf-cookbook.html#Merge</a>) works fine when there is no chart on the slide. </p>

<p>Unfortunately, it seems that the charts are not duplicated with this method: when I try to open the resulting file, Powerpoint detects a problem, tries to repair it, but fails, and I get empty slides. </p>

<p>I've checked the underlying XML files (using Open XML SDK), and it seems that the chart themselves (in the folder <code>/ppt/charts</code>) are not duplicated, and the relationship files (in the folder <code>/ppt/slides/_rels</code>) are not completely updated.</p>

<p>Here is my current code:</p>

<pre class="lang-java prettyprint-override"><code>// Open slideshow
FileInputStream fileInputStream = new FileInputStream(sourceFilePath);
XMLSlideShow slideShow = new XMLSlideShow(fileInputStream);
fileInputStream.close();

// Duplicate slide
XSLFSlideLayout layout = slide.getSlideLayout();
XSLFSlide newSlide = slideshow.createSlide(layout);
newSlide.importContent(slide);

// Save updated slideshow
FileOutputStream fileOutputStream = new FileOutputStream(outputFilePath);
slideShow.write(fileOutputStream);
fileOutputStream.close();
</code></pre>

<p>Do you know how I could clone a slide and its charts ?</p>

<p>Thanks a lot, and best regards!</p>