2011-07-26 36 views
0

如果我去Apache POI XSLF应该有OLE2和OpenXML规范的样本,但只有基于OLE2的恐怖幻灯片布局格式示例。如何使用Apache Poi和XSLF以OpenXML格式创建PowePoint演示文稿?

请问任何人都可以帮我解决XML Slide Layout Format的例子吗? API非常不同。

它不像spreadsheet只是将HSSFWorkbook的实现更改为XSSFWorkbook。

这对XSLF实现看起来如何? POI显然不能从头开始创建文档,所以我们需要一个现有的空虚拟文档,对吧?

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

回答

2

它尚未实现,org.apache.poi版本3.8-beta3,当它将被实现时对我来说是非常未知的。

XMLSlideShow.java

public MasterSheet createMasterSheet() throws IOException { 
    throw new IllegalStateException("Not implemented yet!"); 
} 
public Slide createSlide() throws IOException { 
    throw new IllegalStateException("Not implemented yet!"); 
} 
相关问题