docx4j-multiple-table-example icon indicating copy to clipboard operation
docx4j-multiple-table-example copied to clipboard

Example of how you can generate docx document based on template docx with dynamic header row generation, dynamic data rows generation and multiplying tables.

docx4j-multiple-table-example

In this example project we have few key objectives:

  1. we have to use our super/hyper docx template from our legal/report/whatever deparment,
  2. we have many rows which do not fit on one page,
  3. we need to repeat header on every page,
  4. we have many collumns which do not fit on one page,
  5. we need to generate another table starting from new page, if collumns do not fit on one page.

This solution:

  1. reads docx file with docx4j,
  2. finds template table,
  3. clears template,
  4. splits data into portions that fits on one page,
  5. generates every table with maximum of data,
  6. starts new table on new page if there is more data to write,
  7. at the end it is clearing possibly blank colls.

Dependencies:

  • org.docx4j - docx4j