1, Jacob-1.15-m3-x86.dll Copy to C:\\windows\system32
2. Introduction of Jacob.jar
Copy the Jacob.dll (different versions of Jacob's DLL file name) to the C:\Program Files\java\jdk1.6.0_17\jre\bin directory.
When used on Tomcat, place the supporting Jacob.dll file under the Jdk/jre/bin directory of the JDK used by Tomcat.
Jacob.dll files are placed under the Jdk/jre/bin directory of the JDK installation directory
Jacob.jar and Jacob.dll versions to match import com.jacob.activeX.ActiveXComponent;import com.jacob.com.dispatch;import com.jacob.com.variant; public class word2xml { /** * * @ description: * @param filepath word Catalogue * @param xmlFilePath generate XML storage paths * @author administrator */ public static void Wordtoxml (String filepath,string xmlfilepath) { try { Activexcomponent app = new activexcomponent ( "Word.Application"); //start word app.setproperty ("Visible", new variant (false)); // When set to False when Word is not visible, is true when it is visible or does not see the process of Word opening a file dispatch docs = app.getproperty ("Documents"). ToDispatch (); //Open Editor dispatch doc = dispatch.invoke (docs, "Open", dispatch.method, new object[] {filepath, new variant (False), new variant (True)} , new int[1]). Todispatch (); // Open Word Document Dispatch.call (doc, "SaveAs", xmlfilepath, 11);//xml file Format Macro 11 &nbSp; dispatch.call (doc, "Close", false); app.invoke ("Quit", 0); system.out.println ("--------- Word conversion complete--------"); }catch (Exception e) { E.printstacktrace (); } }}
Save Java Word as Word XML format