custom web design Rotating Header Image

Java program to directly replace Html Word document files

Jacob is a Java and Windows Com under the bridge, through which we can call COM components in Java programs. If your JDK is 1.4, then you need to download Jacob 1.9 of the jni libraries to run properly, the early version of some of the problems under JDK 1.4.
The following is quoted fragment:

 package com; 

  / ** 

  * Title: Word document transfer html class  

  * Description:  

  * Copyright: () 2002  

  * @ Author helmsman 

  * @ Version 1.0 

  * / 

  import com.jacob.com .*; 

  import com.jacob.activeX .*; 

  public class WordtoHtml ( 

  / ** 

  * Document Conversion function 

  * @ Param docfile word document, add the absolute path of the file name (including extension) 

  * @ Param htmlfile converted html file absolute path and file name (without extension) 

  * / 

  public static void change (String docfile, String htmlfile) ( 

  ActiveXComponent app = new ActiveXComponent ("Word.Application"); / / start the word 

  try ( 

  app.setProperty ("Visible", new Variant (false)); 

  / / Set word not visible 

  Object docs = app.getProperty ("Documents"). ToDispatch (); 

  Object doc = Dispatch.invoke (docs, "Open", Dispatch.Method, new Object [] 

  (Docfile, new Variant (false), new Variant (true)), new int [1]). ToDispatch (); 

  / / Open the word document 

  Dispatch.invoke (doc, "SaveAs", Dispatch.Method, new Object [] (htmlfile, 

  new Variant (8)), new int [1]); 

  / / For html format to a temporary file 

  Variant f = new Variant (false); 

  Dispatch.call (doc, "Close", f); 

  ) Catch (Exception e) ( 

  e.printStackTrace (); 

  ) Finally ( 

  app.invoke ("Quit", new Variant []{}); 

  ) 

  )  public static void main (String [] strs) ( 

  WordtoHtml.change ("c: \ \ a \ \ transportation management scheduling system overall program. Doc", "c: \ \ a \ \ t"); 

  ) 

  ) 
Related Posts Plugin for WordPress, Blogger...

Comments are closed.