word| Program | Convert Jacob is a COM bridge under Java and Windows, through which we can invoke COM components in Java programs. If your JDK is 1.4, then you need to download Jacob1.9 's JNI library to work properly, and earlier versions have some problems with JDK1.4.
Package com; /***〈p〉title:word Document Turn HTML Class 〈/p〉*〈p〉description:〈/p〉*〈p〉copyright: () 2002〈/p〉* @author Helmsman * @version 1.0*/import com.jacob.com.*; Import com.jacob.activex.*; public class Wordtohtml {/*** document conversion function * @param docfile the absolute path of the Word document plus the file name (including extension) * @param htmlfile the converted HTML file absolute path and filename (without extension) * * public static void Change (string docfile, String htmlfile) {activexcomponent app = new Activexcomponent ("Word.Application "); Start Wordtry {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 file Dispatch.invoke (doc, "SaveAs", Dispatch.method, new object[] {htmlfile, new Variant (8)}, new int[1]); Save to temporary file as HTML format variant F = new Variant (FALSE); Dispatch.call (Doc, "Close", f); catch (Exception e) {e.printstacktrace ();} finally {App.invoke ("Quit", New variant[]{});} public static voidMain (string[] strs) {Wordtohtml.change ("c:\\a\\ Transport Management Dispatch system overall scenario. Doc", "c:\\a\\t");}
|