Skip to main content

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)

Source distribution for xltemplate 0.2.0
File Size Uploaded
xltemplate-0.2.0.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xltemplate 0.2.0
File Interpreter ABI Platform
xltemplate-0.2.0-py3-none-any.whl Python 3 none any Details

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 log

Release 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 log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page