I am doing a function recently,use apache poi
to exporting powerpoint
, I want to set a different slide transition effect for the slide, but I can't find any method in the apache api
, has anyone ever done anything like this?
Please tell me , thank you !
My English is not very good. I hope you can read it. XD
There is nothing for setting transitions in XSLFSlide and XSLFSheet until now. So we would need using the underlying low level objects of ooxml-schemas-1.4
. Unfortunately there is no documentation for ooxml-schemas
public available. That's why we need downloading the sources and doing javadoc
from them.
Then we find CTSlide
having addNewTransition()
and CTSlideTransition
having different transition elements for example "blinds" element, "checker" element, "circle" element, ...
Example:
import java.io.FileOutputStream;
import org.apache.poi.xslf.usermodel.*;
import org.apache.poi.sl.usermodel.*;
import java.awt.Color;
public class CreatePPTXSheetsTransition {
public static void main(String[] args) throws Exception {
XMLSlideShow slideShow = new XMLSlideShow();
XSLFSlide slide = slideShow.createSlide();
if (slide.getXmlObject().getCSld().getBg() == null) slide.getXmlObject().getCSld().addNewBg();
slide.getBackground().setFillColor(Color.BLUE);
slide.getXmlObject().addNewTransition().addNewDissolve();
slide = slideShow.createSlide();
if (slide.getXmlObject().getCSld().getBg() == null) slide.getXmlObject().getCSld().addNewBg();
slide.getBackground().setFillColor(Color.RED);
slide.getXmlObject().addNewTransition().addNewWheel().setSpokes(8);
FileOutputStream out = new FileOutputStream("CreatePPTXSheetsTransition.pptx");
slideShow.write(out);
out.close();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.