问题
I have a map of data that I want to insert into fields in an existing Microsoft Word Template. Preferably, I'd like to accomplish it using Java. I extracted text from a pdf file and then parsed it for data. Now, I need to figure out how to insert that data into a word template, which serves as a form. By data, I mean things such as name, address, etc.
Is it even possible? I haven't been able to locate any documentation or references that would help me with this task. I've been able to find some stuff on creating MS Word documents, but nothing as far as insertion into template text fields.
回答1:
I've used JWord several times to create documents from template. It's not free but accomplished what I needed.
回答2:
I suggest the ODFDOM project for ODF documents (LibreOffice, OpenOffice open document format, not Microsoft MOOXML format).
You can load an ODF document and modify variables inside it, style and content or you can create a document from scratch.
The project is quite active, the latest version available is 2014-06-02 - ODF Toolkit 0.6.1-incubating.
来源:https://stackoverflow.com/questions/17693553/how-to-insert-data-into-a-microsoft-word-template-using-java