poi导出ppt,里面有个表格,内容超出单元格范围的情况下,office2003的单元格不会变形,但是2007会变成适应文本的大小,什么办啊。。另外,怎样合并单元格???
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();
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();
解决方案 »
- 两个java项目,怎么将一个系统登录后,另一个项目注册session呢
- JSP中点击链接弹出确定取消选择对话框,点确定跳入到JSP处理页面,点取消留在当前页面?怎么写?
- 【100】jquery跨域调用导出excel为什么数据写入excel没有弹出生成的excel?
- 一个不知道怎么描述的问题
- 用JPA注解方式怎样表达这样的数据库表?
- NetBean。。。无语了。
- 紧急!!!sqlserver2005按时间段回滚?
- axis2 自定义异常
- 为什么已经测试数据库连接程序在新建的域中会产生错误???
- 想了解大家都在用java做什么项目,主要是想了解j2ee适合做什么项目
- 一个java多线程问题
- annotation 多对一映射
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版本相匹配,否则后果自负!
然后到apache POI项目页,那里有一大堆的详细例子,肯定能解决你的问题