
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Generates Office documents (PPTX/XLSX) from template files that are flexibly populated or composed using provided context.
Office Templates is a Python library turns PowerPoint (PPTX) and Excel (XLSX) files into reusable templates. Placeholders inside those templates are resolved using provided context so that you can generate templated documents without hard‑coding content.
{{ }}
to access attributes, call methods, filter lists and perform math.upper
, lower
, title
).+
, -
, *
, /
).check_permissions
function.%imagesqueeze%
or %image%
are replaced by an image downloaded from the provided URL.office_templates/
contains the library:
office_renderer/
– logic for rendering PPTX and XLSX files. This handles text boxes, tables, charts, worksheets and the %image%
/%imagesqueeze%
directives.templating/
– the template engine responsible for parsing and evaluating expressions.tests/
– the test suite.Start by looking at the functions in office_renderer
to see how a file is rendered. The templating package is standalone and can be read independently if you want to learn how placeholders are parsed.
Template files are just normal PowerPoint or Excel documents. No coding or macros are required—just type plain text placeholders where you want dynamic information to appear.
{{
and }}
:
{{ user.name }}
– insert a simple value from the context.{{ user.profile__email }}
– read nested attributes using .
or __
.{{ users[is_active=True].email }}
– pick a specific item from a list.{{ amount * 1.15 }}
– perform calculations.{{ price | .2f }}
or {{ name | upper }}
– apply formatting filters.%image%
or %imagesqueeze%
followed by the address:
%image% https://example.com/logo.png
%imagesqueeze% https://example.com/logo.png
The former keeps the image's aspect ratio while fitting it inside the shape. The latter squeezes the image to exactly fill the shape.You can experiment with the example files in office_templates/raw_templates
to see common patterns. Remember that all placeholders are plain text—avoid formulas or punctuation that might confuse the parser.
Chart data sheets can also contain placeholders so your graphs update automatically.
After trying the example templates in raw_templates/
explore the tests/
directory to see many usage patterns. The test files demonstrate complex placeholders, permission checks and the new image replacement behaviour.
Use uv sync --all-extras
to set up the python environment.
FAQs
Generates Office documents (PPTX/XLSX) from template files that are flexibly populated or composed using provided context.
We found that office-templates demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.