When developing a web office system or document system, the PageOffice component is a well-known powerful tool for processing Microsoft word/ppt/excel documents online. It encapsulates various processing of WORD documents at the API level, blocking the complexity of the Office VBA interface without losing the powerful functions of VBA. What we want to share here is a very powerful function of PageOffice encapsulation: obtaining the entry content of word documents. In an office system that includes document processing functions, it is a reasonable requirement for users to automatically analyze the content of each chapter in a word document through a program for various reasons. The interface provided by PageOffice to implement this function is also very simple. Less nonsense, just look at the code:
The specific integration process of PageOffice is skipped here. . . (See the installation instructions in the PageOffice for java development package for details)
1. Call PageOffice to open a word document containing chapter levels online, such as: test.doc
PageOfficeCtrl poCtrl=new PageOfficeCtrl(request);poCtrl.setServerPage(request.getContextPath()+"/poserver.zz");//Open Word document poCtrl.webOpen("doc/test.doc",OpenModeType.docNormalEdit,"Anonymous Zhang"); 2. Add PageOffice code to the area where the file is displayed in the page where the word file is opened (for example: word.jsp):
<div style=" width:1000px; height:650px;"> <%=poCtrl.getHtmlCode("PageOfficeCtrl1")%> </div>3. After the file is opened online, call the following js through buttons or other means, and the variable txt can obtain the content of the document entry:
var txt = document.getElementById("PageOfficeCtrl1").GetWordItemsConent();4. Operation effect:
Summarize
The above is the editor’s introduction to how to obtain the entry content of word documents in Java. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!