Bouke / docx-mailmerge

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

Nested tables add rows to outer table and not inner table #75

Open th1234 opened 4 years ago

th1234 commented 4 years ago

image

Possible Solution When finding the anchor, sort the tables by the number of tables in ascending order. This way the most inner table will be checked first. example code change is to change "for table in part.findall('.//{%(w)s}tbl' % NAMESPACES):" to "for table in sorted(part.findall('.//{%(w)s}tbl' % NAMESPACES), key=len):"

Environment

c-perez-fajardo commented 4 years ago

Hi @th1234 I've the same problems and I newbie in python. Did you find a solution to merge nested tables?