How to generrate odt files from templates in Python

354 Views Asked by At

I'm working on a Python program that takes in input data from a database and open document templates (either .ott or .odt files directly) with anchors.

I would like the program to be able to generate at output .odt files filled with data from the database.

How should I proceed? I saw there were a few libraries that allow to work with opendocument files in python, but most of them are old and no longer maintained. Some suggest to directly modify xml inside documents archives but it seems a bit hacky. I'm surprised that no mainstream library is able to work with opendocument files like so ... am I missing something?

Thank you

1

There are 1 best solutions below

2
Abdulmajeed On

There are several ones but in my experience I enjoyed Odfpy as allows you to create and modify ODT files using Python. It provides a comprehensive API for working with ODT files, including support for text, images, tables, and more.