1

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you Eugene Astafiev. I've abandoned docxtpl because of its limitations and moved to python-docx. I am a novice programmer, but I'm making progress using python-docx. Open XML SDK 2.5 for Office seems way more complicated. Can it be programmed using Python? Is is preferable to python-docx? I've got my hands full just trying to learn Python and am not looking to climb C# mountain. And VB is limited and antiquated.
I am originally a C# (VB) developer, not a Python. The Open XML SDK is a tool developed and supported by MS, so that is a pretty straightforward way of dealing with Office open XML documents.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.