The image below describes what I want to do, so I'm supposed to add many values to this three tables. I'm using the library docx4j
-
1hi, please read https://stackoverflow.com/help/how-to-ask , then edit your question – Leviand Jul 31 '18 at 10:07
-
where is that image which you are referring to? – Muhammad Noman Jul 31 '18 at 11:03
-
there is it on top – Zineb Lalaoui Jul 31 '18 at 11:40
1 Answers
You can use content control databinding for this; docx4j's OpenDoPE convention allows you to repeat table rows. And more recent versions of Word have a concept of repeating content controls; see https://www.docx4java.org/blog/2015/01/word-2013-repeatingsection-content-controls-ready-for-prime-time/
In principle, docx4j supports both, but it'll be easier to get help with the OpenDoPE approach.
To get started, try invoice.docx from https://github.com/plutext/docx4j/tree/master/sample-docs/word/databinding which is an example of repeating table rows.
To merge invoice-data.xml (from the same dir) into it, use https://github.com/plutext/docx4j/blob/master/src/samples/docx4j/org/docx4j/samples/ContentControlsMergeXML.java
If you like this approach, you'll need to author your own input document; to do this, you can try the "friendly" Word AddIn at https://opendope.org/implementations.html

- 15,352
- 4
- 44
- 84