Java handles Word documents (with pictures, table contents)

Source: Internet
Author: User

Because I have long been engaged in the development of OA related projects, so it is unavoidable to deal with Word documents, pdf,excel and so on.

1. Requirements processing Excel can use JXL or poi

2 Require users to fill in the information on the system, save and export the standard Word document. Information that users fill out on the system we use Rich Text Editing Tool kindeditor. This plugin is able to save the user from a table label copied from a Word document. However, the picture information needs to be uploaded separately. Now that the problem comes up, we're going to include these pictures. tables, special symbols of the east to generate Word documents.

The hypothesis is that there is no special lattice character. Pictures and other information, if you want to create a Word document can use the Java+freemark template approach, detailed practice

Use Word to edit the template. Save the template as an Office 2003 XML format, then hit the corresponding label, and finally change the template suffix to. FTL, the freemarker template suffix.

Suppose there is a picture in the content. And the image position is not fixed, this is the need to use the Java + velocity template approach. The detailed process saves the edited Word template as an. MHT single-page document.

Finally, you can adjust the suffix to. vm.

But this process picture is not preserved, this need to cooperate with Java2word. Use java+velocity to generate Word documents. When inserting content into a document, you can replace the picture label with a special string. When the document is claimed to be complete, use the Find and replace function inside the Java2word tool to insert the image into the special character position where we added the content.


Suppose you want to effect the standard Word document, can use Itext I use the itext 2.1.7 altogether three packs, one is the Asian package, this is supports the Chinese language, uses the Litext to be able to draw the standard Word document with the code, especially treats the pagination as well as the table format request strict user.


The above-mentioned Java + velocity is a temporary solution. In fact the simplest solution to the problem of rich text editing with plugins, we purchased the Ntko Office edit plugin for our customers, and we bought the cross-platform version. This plugin can

Let the user edit the Word document online and save the document to the database. But with this plug-in may be the initial system implementation, it takes a lot of effort to operation. Because the user's computer environment is not our developer can around. Wait until a cycle has passed and the effect will be basically better.

Java handles Word documents (with pictures, table contents)

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.