日期:2014-05-20  浏览次数:20718 次

会poi导出ppt的帮一下。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
poi导出ppt,里面有个表格,内容超出单元格范围的情况下,office2003的单元格不会变形,但是2007会变成适应文本的大小,什么办啊。。

另外,怎样合并单元格???

Java code

SlideShow slideShow = new SlideShow();
Slide slide = slideShow.createSlide();

Table table = new Table(2,2);
TableCell cell = table.getCell(0, 0);
RichTextRun richTextRun = cell.createTextRun().getRichTextRuns()[0];
richTextRun.setText("aaaaaaaaaaaaaaaaaaaaaaaaaaa\r\nbbbbbbbbbbbbbbbbbbbbbbbbb");
richTextRun.setFontColor(Color.gray);

cell = table.getCell(0, 1);
richTextRun = cell.createTextRun().getRichTextRuns()[0];
richTextRun.setText("jjjjj\r\nuuu");
richTextRun.setFontColor(Color.yellow);

Line border = table.createBorder();
border.setLineColor(Color.red);
border.setLineWidth(2);
table.setAllBorders(border);

table.setColumnWidth(0, 100);
table.setColumnWidth(1, 100);
table.setRowHeight(0, 100);
table.setRowHeight(1, 100);

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

FileOutputStream fos = new FileOutputStream("e:/a.ppt");
slideShow.write(fos);
fos.close();



------解决方案--------------------
public boolean PPttoHtml(String s, String s1) {
ComThread.InitSTA();
ActiveXComponent activexcomponent = new ActiveXComponent(
"PowerPoint.Application");
String s2 = s;
String s3 = s1;
boolean flag = false;
try {
Dispatch dispatch = activexcomponent.getProperty("Presentations")
.toDispatch();
Dispatch dispatch1 = Dispatch.call(dispatch, "Open", s2,
new Variant(-1), new Variant(-1), new Variant(0))
.toDispatch();
Dispatch.call(dispatch1, "SaveAs", s3, new Variant(12));
Variant variant = new Variant(-1);
Dispatch.call(dispatch1, "Close");
flag = true;
} catch (Exception exception) {
System.out.println("|||" + exception.toString());
} finally {
activexcomponent.invoke("Quit", new Variant[0]);
ComThread.Release();
ComThread.quitMainSTA();
}
return flag;
}

运行条件:
 
1.JDK1.6
 
2.jacob.jar和jacob.dll
 
1) 把jacob.dll在 ..\Java\jdk1.6.0_10\bin、..\Java\jdk1.6.0_10\jre\bin、C:\WINDOWS\system32 目录下各放一份
2) 把jacob.jar放入 项目的lib包下,并且在“java构建路径”中也要加载此jar包。
3) 运行项目即可编译通过.
 
注:jacob.jar以及jacob.dll版本一定要和jdk版本相匹配,否则后果自负!


------解决方案--------------------
先看下相关文档,和导出doc、excel差不多
------解决方案--------------------
poi的版本
------解决方案--------------------
LZ首先要做的是静下心来
然后到apache POI项目页,那里有一大堆的详细例子,肯定能解决你的问题