回4楼你的方法好像读取不了,我刚测式了一下报错了 Exception in thread "main" java.lang.NoSuchMethodError: org.apache.poi.poifs.filesystem.POIFSFileSystem.getRoot()Lorg/apache/poi/poifs/filesystem/DirectoryNode; at org.apache.poi.hslf.HSLFSlideShow.<init>(HSLFSlideShow.java:120) at org.apache.poi.hslf.HSLFSlideShow.<init>(HSLFSlideShow.java:107) at org.apache.poi.hslf.HSLFSlideShow.<init>(HSLFSlideShow.java:94) at org.yeeku.test.ReadPowerPoint.main(ReadPowerPoint.java:15) 我下载是POI包是poi-bin-3.1-beta1-20080428.tar
在方法中我的代码可以实现了,但到jsp页中怎么实现啊? import com.jacob.activeX.ActiveXComponent;import com.jacob.com.ComThread;import com.jacob.com.Dispatch;import com.jacob.com.Variant; public class PPTTest { private static final String PPT_FILE = "E:\\a.ppt"; /** * @param args the command line arguments */ // public void CC(String PPT_FILE){ // AA(PPT_FILE); // } public static void main(String[] args) { //public void AA(String PPT_FILE){ // 新建一个powerpoint程序实例 ActiveXComponent ppt = new ActiveXComponent("PowerPoint.Application"); // 设置程序界面是否可见 ppt.setProperty("Visible", new Variant(true)); ActiveXComponent presentations = ppt.getPropertyAsComponent("Presentations"); // 打开一个现有的 Presentation 对象 ActiveXComponent presentation = presentations.invokeGetComponent("Open",new Variant(PPT_FILE), new Variant(true)); // powerpoint幻灯展示设置对象 ActiveXComponent setting = presentation.getPropertyAsComponent("SlideShowSettings"); // 调用该对象的run函数实现全屏播放 setting.invoke("Run"); // 释放控制线程 ComThread.Release(); } }
package test;
import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.model.Shape;
import org.apache.poi.hslf.model.TextBox;
import org.apache.poi.hslf.usermodel.SlideShow;
public class TestPOI {
/**
* @param args
*/
public static void main(String[] args)
{
try
{
SlideShow ss = new SlideShow(new HSLFSlideShow("C:\\测试.ppt"));
org.apache.poi.hslf.model.Slide[] slides = ss.getSlides();
Shape[] sps = slides[0].getShapes();
System.out.println(((TextBox)sps[0]).getText());
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
}
}
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.poi.poifs.filesystem.POIFSFileSystem.getRoot()Lorg/apache/poi/poifs/filesystem/DirectoryNode;
at org.apache.poi.hslf.HSLFSlideShow.<init>(HSLFSlideShow.java:120)
at org.apache.poi.hslf.HSLFSlideShow.<init>(HSLFSlideShow.java:107)
at org.apache.poi.hslf.HSLFSlideShow.<init>(HSLFSlideShow.java:94)
at org.yeeku.test.ReadPowerPoint.main(ReadPowerPoint.java:15)
我下载是POI包是poi-bin-3.1-beta1-20080428.tar
import com.jacob.activeX.ActiveXComponent;import com.jacob.com.ComThread;import com.jacob.com.Dispatch;import com.jacob.com.Variant;
public class PPTTest { private static final String PPT_FILE = "E:\\a.ppt"; /** * @param args the command line arguments */
// public void CC(String PPT_FILE){
// AA(PPT_FILE);
// }
public static void main(String[] args) {
//public void AA(String PPT_FILE){
// 新建一个powerpoint程序实例 ActiveXComponent ppt = new ActiveXComponent("PowerPoint.Application"); // 设置程序界面是否可见 ppt.setProperty("Visible", new Variant(true)); ActiveXComponent presentations = ppt.getPropertyAsComponent("Presentations"); // 打开一个现有的 Presentation 对象 ActiveXComponent presentation = presentations.invokeGetComponent("Open",new Variant(PPT_FILE), new Variant(true)); // powerpoint幻灯展示设置对象 ActiveXComponent setting = presentation.getPropertyAsComponent("SlideShowSettings"); // 调用该对象的run函数实现全屏播放 setting.invoke("Run"); // 释放控制线程 ComThread.Release(); } }