简体   繁体   English

如何使用apache poi为幻灯片设置不同的幻灯片过渡效果

[英]how to set a different slide transition effect for the slide by use apache poi

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? 我最近在做一个功能,使用apache poi来输出powerpoint ,我想为幻灯片设置一个不同的幻灯片过渡效果,但是我在apache api找不到任何方法,有人做过这样的事情吗?
Please tell me , thank you ! 请告诉我,谢谢!

My English is not very good. 我的英文不是很好。 I hope you can read it. 希望您能阅读。 XD XD

There is nothing for setting transitions in XSLFSlide and XSLFSheet until now. 到目前为止 ,在XSLFSlideXSLFSheet中没有设置过渡的内容 So we would need using the underlying low level objects of ooxml-schemas-1.4 . 因此,我们需要使用ooxml-schemas-1.4的底层低级对象。 Unfortunately there is no documentation for ooxml-schemas public available. 不幸的是,没有可用的ooxml-schemas公共文档。 That's why we need downloading the sources and doing javadoc from them. 这就是为什么我们需要下载源代码并从中执行javadoc的原因。

Then we find CTSlide having addNewTransition() and CTSlideTransition having different transition elements for example "blinds" element, "checker" element, "circle" element, ... 然后我们发现CTSlide具有addNewTransition()CTSlideTransition具有不同的过渡元素,例如“ blinds”元素,“ checker”元素,“ circle”元素,...

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();
 }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM