3

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

image

L_J
  • 2,351
  • 10
  • 23
  • 28

1 Answers1

0

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

JasonPlutext
  • 15,352
  • 4
  • 44
  • 84