When I use a XLSX file as database in my python-docx-template, the output file came with bugs.
The XLSX file contains:
name birth gender
Felipe 07/04/1988 male
My template in docx contains:
My name is {{ name }}, i am {{ gender }} and i was born in {{ birth }}.
This is my code:
import pandas as pd
from docxtpl import DocxTemplate
file_path = 'test.xlsx'
df = pd.read_excel(file_path, encoding='utf-8')
data = df.to_dict()
doc = DocxTemplate("modelo.docx")
context = data
doc.render(context)
doc.save("generated_doc.docx")
but, when the "generated_docx" is created, it contains the text:
My name is {0: 'Felipe'}, i am {0: 'male'} and i was born in {0: Timestamp('1988-04-07 00:00:00')}.
What am I doing wrong??