Skip to content

Repository files navigation

fillxl

PyPI version License: MIT Python 3.11+ CI Docs

Fill Excel templates with data from Python.

Designed around named cells and Excel tables — no more fragile cell references like A1 or B3. Charts, formulas, formatting, and conditional formatting are preserved and updated automatically.

Fill tables using list, pandas, polars or duckdb!

from fillxl import fill
import pandas as pd

fill(
    template="report_template.xlsx",
    output="q4_report.xlsx",
    tables={
        "Products": [
            {"Name": "Widget", "Price": 4.99, "Sold": 150},
            {"Name": "Gadget", "Price": 9.99, "Sold": 85},
        ],
        "Sales": pd.read_csv('sales_data.csv'),
    },
    values={
        "ReportTitle": "Q4 2024 Sales",
        "PreparedBy": "Alice",
    },
)

Installation

pip install fillxl

Optional extras:

pip install fillxl[pandas]   # pandas support
pip install fillxl[all]      # pandas + polars + duckdb

Quick Start

  1. In Excel, create named cells (Name Manager) for single values and Excel Tables (Ctrl + T) for tabular data.
  2. Fill the template with the code above.

Tables are automatically resized, charts updated, and all formatting preserved.

Backend (optional)

fill(..., engine="openpyxl")   # default, cross-platform
fill(..., engine="win32com")   # Windows + Excel installed (maximum fidelity)

Visual Example

Before filling:

Before fill

After filling — data, chart, and values populated:

After fill

📖 See the code that produced this


Main Features

  • Populate named cells and Excel tables
  • Automatic table resizing + chart range updates
  • Conditional formatting and pivot table refresh
  • Two backends: openpyxl (default) and win32com (Windows + Excel)

API

fill()

fill(
    template: str | Path,
    output: str | Path,
    values: dict[str, Any] | None = None,
    tables: dict[str, list[dict] | DataFrame | ...] | None = None,
    *,
    engine: str = "auto",      # "openpyxl", "win32com"
    config: FillXLConfig | None = None
) -> Path

See the full documentation for FillXLConfig options.


Supported Data Sources

  • list[dict]
  • dict[str, list]
  • pandas.DataFrame
  • polars.DataFrame
  • duckdb.DuckDBPyRelation

Backends

Engine Cross-platform Requires Excel Best for
openpyxl Yes No Most use cases, Linux/macOS
win32com Windows only Yes Modern charts, full fidelity

Performance

Benchmark: 5,000 rows × 20 columns (list[dict] data).

Method Engine Time (mean ± std)
fillxl openpyxl 2.26s ± 0.03s
fillxl win32com 2.80s ± 0.03s
pandas.to_excel openpyxl 3.01s ± 0.09s

Known Limitations

  • openpyxl does not support dynamic arrays, .xlsm, or .xlsb files and drops some modern chart types.
  • win32com requires Windows + Excel.
  • Timezone-aware datetimes are converted to naive.

Development

The project will initially stay at 0.X.X to allow early adopters to try out the package. Once it has been out for while version will be bumped to 1 to signal stability.

No new features are planned, and new features will purly be driven by the community.

git clone https://github.com/hirolau/fillxl.git
cd fillxl
uv sync --all-extras
uv run pytest

Supported: Python 3.11–3.14, Windows/Linux (macOS best-effort).
License: MIT

About

Excel Template Filler

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages