jskyme 发表于 2013-2-7 17:01:32

Word文档转html

参考资源:http://www.iteye.com/topic/356374
public void WordToHtml(String filename, String savefilename)   
    {   
      ActiveXComponent app = new ActiveXComponent("Word.Application");// 启动word   
      try
      {   
            app.setProperty("Visible", new Variant(false));   
            // 设置word不可见   
            Object docs = app.getProperty("Documents").toDispatch();   
            Object doc = Dispatch.invoke((Dispatch)docs, "Open", Dispatch.Method, new Object[] { filename, new Variant(false), new Variant(true) }, new int).toDispatch();   
            // 打开word文件   
            Dispatch.invoke((Dispatch)doc, "SaveAs", Dispatch.Method, new Object[]{ savefilename, new Variant(8) }, new int);   
            // 作为html格式保存到临时文件   
            Dispatch.call((Dispatch)doc, "Close", new Variant(false));   
      }   
      catch (Exception e)   
      {   
            e.printStackTrace();   
      }   
      finally
      {   
            app.invoke("Quit", new Variant[]{});   
            app = null;   
      }   
    }
页: [1]
查看完整版本: Word文档转html