Rycliff
Rycliff

Reputation: 127

Using docxtpl library in Python, how to generate complex Word documents from multiple tables of different data?

Using docxtpl library in Python to generate complex Microsoft Word documents from Excel data, is it possible to generate a single document from multiple "contexts" or tables?

For example, list1 contains people with data about each person, and list2 contains issues with data about each issue, and list3 contains data pertaining to relationships between the different people and different issues, and list4 contains data regarding the overall case.

Each table can have a varying and unlimited number of rows of data. And I want to have conditional statements and nested for loops through different tables at different points in the document to generate complex and dynamic paragraphs of text in the Word document.

How do you feed the "context" variable all that data from different tables of data? Examples I see online feed the "context" variable a single table.

Thank you for your help.

Upvotes: 1

Views: 727

Answers (1)

Eugene Astafiev
Eugene Astafiev

Reputation: 49397

You can use the Open XML SDK for generating Word documents, see Welcome to the Open XML SDK 2.5 for Office for more information. As for Python, you may find the python-docx and python-ooxml libraries helpful.

Upvotes: 1

Related Questions