Dear all,

 

I'm working with Apache POI and I'm trying to automate some tasks with
Powerpoint reports. More precisely, I would like to update the data inside a
.pptx presentation from code, including embedded Excel spreadsheets
(displayed as table).

 

So far, I've managed to update the embedded spreadsheet itself, but the pptx
presentation is not "refreshed": when I open the file, the old value is
visible, but the new value shows up when I double-click on the grid
(entering "edit" mode).

 

According to Gagravarr's comment this post
http://stackoverflow.com/questions/17890549/unable-to-see-apache-poi-updated
-data-value-in-barchart-in-pptx-without-editing, this behavior is expected:
the underlying file is indeed updated, but the pre-rendered version remains.

 

As a result, I would like to "refresh" the pre-rendered version: do you know
how I can do that with Apache POI? (or at least "zap" this pre-rendered
version and hope that Powerpoint will re-render it when I open the
slideshow).

 

I'm not familiar with POI users list archives, so I'm sorry if the answer
was there somewhere. 

 

Here is my current code:

// Open SlideShow
FileInputStream fileInputStream = new FileInputStream(sourceFilePath);
XMLSlideShow slideShow = new XMLSlideShow(fileInputStream);
fileInputStream.close();
 
 
// Get PackagePart (shortened version)
PackagePart excelEmbedding = slideshow.getAllEmbedds().get(3);
 
 
// Update underlying spreadsheet (shortened version)
InputStream is = excelEmbedding.getInputStream();
XSSFWorkbook workbook = new XSSFWorkbook(is);    
 
XSSFRow row = sheet.getRow(1);
XSSFCell cell = row.getCell(3);
cell.setCellValue("TEST");
 
OutputStream os = excelEmbedding.getOutputStream();
workbook.write(os);
os.close();
workbook.close();
 
 
// Save changes
FileOutputStream fileOutputStream = new FileOutputStream(targetFilePath);
slideShow.write(fileOutputStream);
fileOutputStream.close();

 

Remark: I have also posted this question on stackoverflow:
http://stackoverflow.com/questions/35012191/how-to-refresh-embedded-content-
in-a-pptx-using-apache-poi

 

Thanks a lot, and best regards!

 

-- 

Romain André-Lovichi

 

Reply via email to