Py3o Template

raw JSON →
0.10.0 verified Fri May 01 auth: no python

An easy solution to design reports using LibreOffice templates (ODT/ODS) and Python. Current version 0.10.0, with releases approximately yearly.

pip install py3o-template
error ModuleNotFoundError: No module named 'py3o'
cause Package not installed or environment mismatch.
fix
Run 'pip install py3o-template' to install the package.
error AttributeError: 'Template' object has no attribute 'set'
cause Incorrect version usage. In older versions, the method was named 'set' but in newer it might be 'render' or 'process'. Or wrong API.
fix
Check documentation for the correct method. For 0.10, use 'set' but ensure you have the latest version.
gotcha Template files must be ODT format, not OTT (template files). Py3o-template does not handle OTT files.
fix Use .odt files as templates. Save .ott as .odt first.
gotcha Variable substitution syntax conflicts: Jinja2-like syntax may conflict with LibreOffice's own field syntax. Use the correct py3o syntax (e.g., ${variable} in text, or py3o directives).
fix Use the py3o documentation for proper placeholder syntax; ensure no conflicts.

Basic usage: load a LibreOffice template, set variables, render.

from py3o.template import Template

# Load an ODT template file
t = Template(template_path='my_template.odt', out_path='my_output.odt')

# Set data
my_data = {'name': 'John Doe', 'age': 30}
t.set(my_data)

# Render the output
t.render()