Bouke / docx-mailmerge

Mail merge for Office Open XML (docx) files without the need for Microsoft Office Word.
MIT License
274 stars 104 forks source link

merge_templates with blank tables causes rows from another table to be written instead #88

Open cameronstubber opened 3 years ago

cameronstubber commented 3 years ago

Expected Behavior

If I submit 3 sets of data to merge_templates, and only 1 contains table rows, I expect that only 1 of the pages should contain the table rows, not more than 1. I also expect where the table should be blank, that the table rows are actually blank.

Current Behavior

The item previous in the array of inputs seems to be given the next pages table rows, if the previous pages rows were empty.

Possible Solution

Possibly an indexing or pointer issue?

Steps to Reproduce (for bugs)

  1. Set up a merge_template with page data
  2. Ensure that only 1 page has table rows defined
  3. Run the script
  4. Observe that more than one page contains a duplicate of the table rows.

Context

I am trying to write an audit report, which validates parts used to be booked to jobs. The impact of this bug is that the wrong list of parts can appear on a job where it should have no parts (Like an Inspection).

Your Environment

cameronstubber commented 3 years ago

Workaround:

it is possible to get around this issue by ensuring that all pages have at least 1 table row supplied. In the case of an empty table, simply create a row where the columns say NA or Empty or something similar.

iulica commented 2 years ago

Can you provide a sample docx and merge_templates code ?