Comparison of bookmarkdon_javascript skills for obtaining Word documents from java and javascript

Source: Internet
Author: User
This article mainly introduces the code comparison between java and javascript to obtain the bookmarks of Word documents. For more information, see section 1. javascript: Open activex in IE and use the following webpage to view the order and position of bookmarks:

《script》var word;word = new ActiveXObject("Word.Application");var range = word.Range;word.Visible = true;var path = "D:\\xxx\\xxx\\xx.doc";word.Documents.Open(path);for(var i=1;i<=word.ActiveDocument.Bookmarks.count;i++){ document.write(word.ActiveDocument.Bookmarks(i).Name); document.write(" "); document.write(word.ActiveDocument.Bookmarks(i).Range.BookmarkID); document.write("
");}《script》

Java: open with poi, and use the. DOC file. Therefore, use the old set of poi APIs. If it is docx, the principle is the same.

FileInputStream in = new FileInputStream("D:\\xxx\\xxx\\xx.doc");HWPFDocument doc = new HWPFDocument(in);Bookmarks bookmarks = doc.getBookmarks();for(int i=0,j=bookmarks.getBookmarksCount();i
 
Related Article

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.