I am using docxtpl and pandas to generate a Word document that contains multiple labels created using docxtpl.
I have an Excel file containing the data for the labels and a document with Jinja syntax. My goal is to generate a document that includes all the labels, one after another, with a page break between each label.
Here is the code snippet I have tried:
# Number of labels:
for i in range(len(excel_file)):
# Content to add within the labels:
context = {'NUMBER': number}
template.render(context)
template.save("foo.docx")
However, this code only generates the last label. I also attempted to use the docx library, but I was unable to achieve the desired result.
I would greatly appreciate any assistance with this issue.