首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Apache Poi和XSLF创建OpenXML格式的PowePoint演示文稿?

如何使用Apache Poi和XSLF创建OpenXML格式的PowePoint演示文稿?
EN

Stack Overflow用户
提问于 2011-07-27 04:45:13
回答 1查看 1.9K关注 0票数 0

如果我去Apache POI XSLF,应该有OLE2和OpenXML规范的示例,但只有基于OLE2的可怕幻灯片布局格式的示例。

有没有人能帮我举个XML幻灯片布局格式的例子?API则完全不同。

它不像spreadsheet那样,只需将HSSFWorkbook的实现更改为XSSFWorkbook。

这在XSLF实现中会是什么样子?POI显然不能从头开始创建文档,所以我们需要一个现有的空虚拟文档,对吧?

代码语言:javascript
复制
      //table data              
      String[][] data = {
          {"INPUT FILE", "NUMBER OF RECORDS"},
          {"Item File", "11,559"},
          {"Vendor File", "300"},
          {"Purchase History File", "10,000"},
          {"Total # of requisitions", "10,200,038"}
      };

      SlideShow ppt = new SlideShow();

      Slide slide = ppt.createSlide();
      //create a table of 5 rows and 2 columns
      Table table = new Table(5, 2);
      for (int i = 0; i < data.length; i++) {
          for (int j = 0; j < data[i].length; j++) {
              TableCell cell = table.getCell(i, j);
              cell.setText(data[i][j]);

              RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
              rt.setFontName("Arial");
              rt.setFontSize(10);

              cell.setVerticalAlignment(TextBox.AnchorMiddle);
              cell.setHorizontalAlignment(TextBox.AlignCenter);
          }
      }

      //set table borders
      Line border = table.createBorder();
      border.setLineColor(Color.black);
      border.setLineWidth(1.0);
      table.setAllBorders(border);

      //set width of the 1st column
      table.setColumnWidth(0, 300);
      //set width of the 2nd column
      table.setColumnWidth(1, 150);

      slide.addShape(table);
      table.moveTo(100, 100);

      FileOutputStream out = new FileOutputStream(file);
      ppt.write(out);
      out.close();
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-07-27 07:20:53

它还没有实现,org.apache.poi版本3.8-beta3,什么时候实现对我来说是非常未知的。

XMLSlideShow.java

代码语言:javascript
复制
public MasterSheet createMasterSheet() throws IOException {
    throw new IllegalStateException("Not implemented yet!");
}
public Slide createSlide() throws IOException {
    throw new IllegalStateException("Not implemented yet!");
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6836386

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档