How to insert data into a Microsoft Word Template using Java?

19.5k Views Asked by At

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.

2

There are 2 best solutions below

1
On

I've used JWord several times to create documents from template. It's not free but accomplished what I needed.

6
On

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.