P
P
pfedorov0310902022-04-12 10:23:57
Python
pfedorov031090, 2022-04-12 10:23:57

Formation of a document according to a template?

Good day!

The essence of the question is as follows:
1. There is a data source - a database on MySQL (or you can upload it to EXCEL)
2. There is a WORD template in which you need to insert data.
But there is one problem. In all the examples on the Internet, the WORD template is filled in once, but I need it to be replenished depending on the amount of data.
Example:
There is a template (in the screenshot)
625528d5be15b595014115.png
But you need to create as many tables as in the screenshot in the finished report as there are rows in EXCEL. (Or in the case of a data source - a database, how many client IDs we will pass to the script.) That is, at the stage of writing automation, we do not know this.

I tried to make it a Python script, but I don't know how to add a new template table on a new loop step in the same document. It's the same with the Mail Merge feature in Word tools.

Please tell me if there is a solution. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Golovanenko, 2022-04-12
@drygdryg

You can use the python-docx library to generate the document.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question