Generate PowerPoint 2007/2010 file using Java

Viewed 28274

Does anyone know of any API (commercial or open-source) that can generate/edit PowerPoint 2007/2010 presentations through Java. I have a template in the PowerPoint 2007/2010 format that I require to edit/update. So far I have been converting the .pptx file to xml and then editing and storing it back as .pptx. But the file gets corrupted while opening.

Is anyone aware of any other method or API that do this in Java?

6 Answers

Yes. Check this out http://poi.apache.org/, they just released version 3.6 which now supports Office 2007 format documents. The best part is that it's free!

To generate a PowerPoint presentation from a template file, you can use PPT Templates.

This library provides a fluent API to replace variables inside the PPT template:

try(FileOutputStream out = new FileOutputStream("generated.pptx")) {
  new PptMapper()
    .text("variable", "Hello")
    .text("other_variable", "World!")
    .processTemplate(PptTemplateDemo.class.getResourceAsStream("/title.pptx"))
    .write(out);
}

With this library, you can process text and images in the template.

Another solution that may work for you is Windward Reports (disclaimer, I'm the founder & CEO there). It uses PPTX as one of the supported template formats and merges in data to then generate a PPTX (or PDF, etc.) output.

If the edit/update you need can be handled via the data tags in Windward, this should be trivial for you. If what you need cannot be handled by the tags, then this won't work for you.

Well as mentioned by GrantB best way is to create a template, then load the template , traverse the xml graph,update the data and stream out to a output ppt. We recently did it to generate reports for clients that had complex visuals and charts in ppt. You can have a look here generate ppt in java

Related