如果我去Apache POI XSLF,应该有OLE2和OpenXML规范的示例,但只有基于OLE2的可怕幻灯片布局格式的示例。
有没有人能帮我举个XML幻灯片布局格式的例子?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();发布于 2011-07-27 07:20:53
它还没有实现,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!");
}https://stackoverflow.com/questions/6836386
复制相似问题