Reputation: 2992
I am removing slides from a ppt file using apache poi.
HSLFSlideShow slideShow = new HSLFSlideShow(new HSLFSlideShowImpl(dir));
for (int i = 0; i < 5; i++) {
slideShow.removeSlide(0);
}
I printed all the slides and I saw the first five slides are gone. However when I opened my ppt file, nothing has changed. The first five slides are still there. What should I do?
Upvotes: 0
Views: 180
Reputation: 48326
When you're done making changes, you need to write them out for them to be saved! The method is generally write(OutputStream)
across all the formats, javadocs for the HSLF write method here
So, just change your code to something like this:
HSLFSlideShow slideShow = new HSLFSlideShow(new HSLFSlideShowImpl(dir));
for (int i = 0; i < 5; i++) {
slideShow.removeSlide(0);
}
FileOutputStream out = new FileOutputStream("changed.ppt");
slideShow.write(out);
out.close();
There's currently no in-place saving support in HSLF, and no volunteer to add it, so you'll have to save out to a different file than the one you opened it from
Upvotes: 1