Answer the question
In order to leave comments, you need to log in
Python populate word table?
Hello everyone, I'm making a program that solves industrial security tests. saves correct answers. there is one but. A Word document template with a header and a beautiful table is ready. Q&A and subheadings. how to fill this document programmatically?
Answer the question
In order to leave comments, you need to log in
If the template is ready, try docxtpl .
Algorithm:
1. First, in the word template, write tags in the form {{ }} at the insertion point.
2. In the program, generate a docx file based on the template. In the generated document, the tags will be replaced with the desired values.
Example from documentation :
from docxtpl import DocxTemplate
doc = DocxTemplate("my_word_template.docx")
context = { 'company_name' : "World company" }
doc.render(context)
doc.save("generated_doc.docx")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question