Java Word Save as Word XML format

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.