[Original]java merge Word file

Source: Internet
Author: User

Requirements background

In the Internet education industry, content-related projects often encounter a problem is how to dynamically generate a word test paper. In advance, each of the questions in the question bank has been saved as a separate Word file, but when you select a part of the test to generate a word paper, if you can not use the Java program to merge the selected word test file, Then you can only manually input and copy the way to merge word content, inefficient, and labor costs and input error rate is higher.

Problem points

The difficulties of using POI to achieve word merging are mainly as follows:

    • Word structure problem--word is not open source, and contains a lot of non-textual content, compared to tables, pictures, and the known general method can only parse plain text content, so if you do not know the internal hierarchy of Word, parsing will be difficult to do.
    • Word version issue--currently word has docx and doc two document formats, is parsing all compatible? Of course, the premise is that a type has been successfully parsed.
    • Word spec problem-some word may be made early, rework is too expensive, so the format content is varied. And even if you make the Word format specification, the new Word does not guarantee that the format must be correct.

Use Jacob to implement the problems that Word document merging faces:

    • The server must be a Windows operating system-the Web project is now more Java-developed because the server can be a non-Windows system such as Linux and UNIX to reduce the cost of the project.
    • The Office--jacob that must be installed on the server means that the COM interfaces provided by Office are invoked in Java COM Bridge,java to implement operations on Office files.
    • Concurrency problem-If multiple users generate Word files online at the same time, they have to deal with this concurrency problem and, with a slight carelessness, will generate the dead process of office on the server side, and the memory resources of the deadlock server.
Solution Solutions

After a period of time, the progress is slow, in the process of repeated Baidu found that Pageoffice provides a good solution, and in the Pageoffice sample program has a relevant demonstration, Just Pageoffice's demo example is to save the Word file as a binary stream in the database, just save the Word file in your own project by using a disk file instead. The Pageoffice solution uses a call to the client Office interface for Word document merging, which solves the problem of Word formatting, version issues, specification issues, and multi-user concurrency issues, and is perfect for server-side requirements.

Pageoffice for Java Development package: http://www.zhuozhengsoft.com/dowm/, copy the extracted Samples4 folder to the Webapps directory of Tomcat, visit: http:/ /localhost:8080/samples4/index.html, see the comprehensive demo: three, 2, dynamically generate a quiz paper in a Word document

  

  

  

[Original]java merge Word file

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.