poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain André-Lovichi <romain.andrelovi...@gmail.com>
Subject How to duplicate a slide containing a chart using apache POI?
Date Wed, 17 Feb 2016 10:58:48 GMT
Dear all,

I'm working with Apache POI and I would like to duplicate a slide
containing several charts from code (this slide is a "template" that will
be used with dozens of datasets with the same structure).

The code below (inspired by
https://poi.apache.org/slideshow/xslf-cookbook.html#Merge) works fine when
there is no chart on the slide.

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.

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

Here is my current code:

   // Open slideshow
   FileInputStream fileInputStream = new FileInputStream(sourceFilePath);
   XMLSlideShow slideShow = new XMLSlideShow(fileInputStream);

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

   // Save updated slideshow
   FileOutputStream fileOutputStream = new FileOutputStream(outputFilePath);

Do you know how I could clone a slide and its charts ?

I've also found a way using JACOB and COM components, but I'm not really
happy with it.

Remark: I have also posted this question on StackOverflow:

Thanks a lot, and best regards!

Romain André-Lovichi

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message