将PPT文件转换成HTML文件

来源:互联网 发布:沃尔玛用什么收银软件 编辑:程序博客网 时间:2024/05/22 05:10

1.用JCOB1.9做的

2.源码如下:

public class FileConversion {
 private static  ActiveXComponent  axp;
 private static Dispatch dphAll;
 private static Dispatch dph;
 /**
  * 将PowerPoint转化为html
  * @param comFile
  * @param toFile
  */
 public  static void powerPointToHtml(String comFile,String toFile)
 {
       try {
      axp   =   new   ActiveXComponent("PowerPoint.Application");//启动PowerPoint
         dphAll= (Dispatch)  axp.getProperty("Presentations").toDispatch();  
         axp.setProperty("Visible",   new   Variant(true));//设置PowerPoint不可见
         dph= (Dispatch)  Dispatch.invoke(dphAll,"Open",
           Dispatch.Method,new   Object[]{comFile,new   Variant(false),   new   Variant(false)}, 
           new   int[1]).toDispatch();//打开临时文件  
         Dispatch.invoke(dph,"SaveAs",   Dispatch.Method,   new   Object[]{toFile,new   Variant(12)},
           new   int[1]);//以html格式保存
         Dispatch.call(dph,   "Close");     
       }    
       catch   (Exception   e)    
       {  
          e.printStackTrace();  
         }    
       finally    
       {  
      
             axp.invoke("Quit",   new   Variant[]{}); 
             ComThread.Release();
       }
 }
}

原创粉丝点击