OiO.lk English java DOCX4J to generate report from existing templates simplification
java

DOCX4J to generate report from existing templates simplification


I am using Java 17+, together with docx4j. I need to read a Word document template that has
header with placeholder ${creationDate} and has a table in the document body with the following information:

ID    | First Name   |  Last Name  |  Age   |  Gender  |
-----------------------------------------------------------
${id} | ${firstName} | ${lastName} | ${age} | ${gender} |

and generate a new document that will replace the placeholder with data from the application.
In the table, we might have more than one person, so we need to implement docx4j to replace a row with a placeholder for multiple rows of data that we might have.

This looked simple at first, but it took me longer then, I expected. I used docx4j to implement this issue and I am using StackOverflow to document this solution.

If someone has a better way to do it, i will reward that as an accepted answer.



You need to sign in to view this answers

Exit mobile version