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",
},
)pip install fillxlOptional extras:
pip install fillxl[pandas] # pandas support
pip install fillxl[all] # pandas + polars + duckdb- In Excel, create named cells (Name Manager) for single values and Excel Tables (
Ctrl + T) for tabular data. - 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)Before filling:
After filling — data, chart, and values populated:
📖 See the code that produced this
- Populate named cells and Excel tables
- Automatic table resizing + chart range updates
- Conditional formatting and pivot table refresh
- Two backends:
openpyxl(default) andwin32com(Windows + Excel)
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
) -> PathSee the full documentation for FillXLConfig options.
list[dict]dict[str, list]pandas.DataFramepolars.DataFrameduckdb.DuckDBPyRelation
| Engine | Cross-platform | Requires Excel | Best for |
|---|---|---|---|
openpyxl |
Yes | No | Most use cases, Linux/macOS |
win32com |
Windows only | Yes | Modern charts, full fidelity |
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 |
openpyxldoes not support dynamic arrays,.xlsm, or.xlsbfiles and drops some modern chart types.win32comrequires Windows + Excel.- Timezone-aware datetimes are converted to naive.
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 pytestSupported: Python 3.11–3.14, Windows/Linux (macOS best-effort).
License: MIT