在Java编程中,如何创建一个空的PPT文档?
注意:需要访问网址: , 下载一个Apache POI软件包。这里下载最新版本:poi-bin-3.17-20170915.tar.gz解压并全部导入 。
需要导入全部包,如下图所示 –
以下是使用Java创建空PPT文档的程序。
package com.yiibai; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.xslf.usermodel.XMLSlideShow; public class CreatingBlankPPT { public static void main(String args[]) throws IOException { // creating a new empty slide show XMLSlideShow ppt = new XMLSlideShow(); // creating an FileOutputStream object File file = new File("blank_ppt.pptx"); FileOutputStream out = new FileOutputStream(file); // saving the changes to a file ppt.write(out); System.out.println("Presentation created successfully"); out.close(); } }
执行上面示例代码,得到以下结果 –
Presentation created successfully
这就创建一个空的PPT文件了。
¥ 我要打赏 纠错/补充 收藏