xltemplate
A lightweight Python wrapper around openpyxl that provides a clean, stateful OOP interface for populating Excel templates with DataFrames while preserving formatting.
Installation
pip install xltemplate # Core only
pip install xltemplate[pandas] # With Pandas support
pip install xltemplate[polars] # With Polars support
pip install xltemplate[all] # With both
Quick Start
from xltemplate import Workbook
import pandas as pd
# Load an existing template
wb = Workbook("template.xlsx")
# Write a DataFrame starting at row 5, column 2
df = pd.DataFrame({"Name": ["Alice", "Bob"], "Score": [95, 87]})
wb.sheet("Summary").write_df(df, row=5, col=2)
# Save to a new file
wb.save("output.xlsx")
Features
- First-class Pandas & Polars support — Pass either DataFrame type to
write_df() - Format preservation — Existing cell styles are preserved by default
- Formula preservation — Cells containing formulas are skipped by default
- Clean API — Stateful, chainable methods inspired by R's openxlsx
API Reference
Workbook
wb = Workbook("template.xlsx") # Load existing workbook
wb.sheet("SheetName") # Get Sheet object
wb.sheet_names # List all sheet names
wb.save("output.xlsx") # Save to file
Sheet
sheet = wb.sheet("Data")
# Write DataFrame
sheet.write_df(
df,
row=1, # Starting row (1-indexed)
col=1, # Starting column (1-indexed)
headers=True, # Include column headers (default: True)
preserve_format=True, # Keep existing cell formatting (default: True)
preserve_formulas=True # Skip cells with formulas (default: True)
)
# Write single value
sheet.write_value("Hello", row=1, col=1)
# Get sheet name
sheet.name
License
MIT
Metadata
Release files for xltemplate 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xltemplate-0.2.0.tar.gz | 10.4 kB | With provenance | Details for xltemplate-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xltemplate-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for xltemplate-0.2.0-py3-none-any.whl |
Total release size: 19.3 kB
Release files / xltemplate-0.2.0.tar.gz
| Download URL | xltemplate-0.2.0.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c9f536b9854b90ee61fa2e325ea1ced931b96348dba38709f3928af6ee326df1
|
|
BLAKE2b-256 checksum How to use checksums |
aad500ecc9703785831df70b2745416eb0badead57d6e6523fc78dab2dade9a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 20, 2026.
Transparency logRelease files / xltemplate-0.2.0-py3-none-any.whl
| Download URL | xltemplate-0.2.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
312f6e5c67e248c3fd0828e888849809a6818ac8088018960b350eb9e8aca48c
|
|
BLAKE2b-256 checksum How to use checksums |
4986347325ee28e85f290b8456dea2de1a5f4f3df61cf36e6756e20830262982
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 20, 2026.
Transparency logSecurity for xltemplate 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for xltemplate-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.