iulica / docx-mailmerge

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

merge same field in multiple tables #24

Closed tolot27 closed 2 months ago

tolot27 commented 2 months ago

I have several tables in my docx template which have an identifier column in common. If I specify a merge field with the same field name and use merge_rows, only the first table is populated with the rows.

How can I apply merge_rows to every table which contains the same field name specified in merge_rows?

Your Environment

iulica commented 2 months ago

Hi,

let me see if I understood it correctly. You have several tables that should be filled with the same data, right?

One workaround would be to just use a different identifier and fill the data separately.

I will look into the code to see if there is a problem there.

tolot27 commented 2 months ago

You got it right. Your proposed workaround requires to duplicate the json data in python with different identifiers several times (=number of tables).

Maybe https://github.com/iulica/docx-mailmerge/blob/master/mailmerge.py#L571 can be repeatedly called until it returns None?

iulica commented 2 months ago

Fixed, and released 0.8.1 . Please wait a little bit for the release to be published and then check if it works.