Create styled excel reports with declarative python.
Project description
xpyxl — Excel in Python
Compose polished spreadsheets with pure Python—no manual coordinates. You assemble rows/columns/cells; xpyxl handles layout, rendering, and styling with utility-style classes.
Core ideas
- Positionless composition: Build sheets declaratively from
row,col,cell,table,vstack, andhstack. - Composable styling: Tailwind-inspired utilities (typography, colors, alignment, number formats) applied via
style=[...]. - Deterministic rendering: Pure-data trees compiled into
.xlsxfiles with predictable output—ideal for tests and CI diffing.
Getting started
import xpyxl as x
report = (
x.workbook("Sales")[
x.sheet("Summary")[
x.row(style=[x.text_2xl, x.bold, x.text_blue])["Q3 Sales Overview"],
x.row(style=[x.text_sm, x.text_gray])["Region", "Units", "Price"],
x.row(style=[x.bg_primary, x.text_white, x.bold])["EMEA", 1200, 19.0],
x.row()["APAC", 900, 21.0],
x.row()["AMER", 1500, 18.5],
]
]
)
report.save("report.xlsx")
Primitives
x.row(style=[x.bold, x.bg_warning])[1, 2, 3, 4, 5]
x.col(style=[x.italic])["a", "b", "c"]
x.cell(style=[x.text_green, x.number_precision])[42100]
row[...]accepts any sequence (numbers, strings, dataclasses…)col[...]stacks values verticallycell[...]wraps a single scalar- All primitives accept
style=[...]
Component: table
x.table(...) renders a header + body with optional style overrides. Combine with vstack/hstack for dashboards and reports.
sales_table = x.table(
header=["Region", "Units", "Price"],
header_style=[x.text_sm, x.text_gray, x.align_middle],
style=[x.table_bordered, x.table_compact],
)[
["EMEA", 1200, 19.0],
["APAC", 900, 21.0],
["AMER", 1500, 18.5],
]
layout = x.vstack(
x.row(style=[x.text_xl, x.bold])["Q3 Sales Overview"],
x.space(),
x.hstack(
sales_table,
x.cell(style=[x.text_sm, x.text_gray])["Generated with xpyxl"],
gap=2,
),
)
Utility styles (non-exhaustive)
- Typography:
text_xs/_sm/_base/_lg/_xl/_2xl/_3xl,bold,italic,mono - Text colors:
text_red,text_green,text_blue,text_orange,text_purple,text_black,text_gray - Backgrounds:
bg_red,bg_primary,bg_muted,bg_success,bg_warning,bg_info - Layout & alignment:
text_left,text_center,text_right,align_top/middle/bottom,wrap - Tables:
table_bordered,table_banded,table_compact - Number/date formats:
number_comma,number_precision,percent,currency_usd,currency_eur,date_short,datetime_short,time_short
Mix and match utilities freely—what you see is what you get.
Layout helpers
vstack(a, b, c, gap=1)vertically stacks components with optional blank rows between them.hstack(a, b, gap=1)arranges components side by side with configurable column gaps.space(rows=1, height=None)inserts empty rows (optionally with a fixed height).
Examples
- Multi-sheet sales demo: see
examples/multi_sheet_sales_demo.py.- Run it to generate a showcase workbook:
python examples/multi_sheet_sales_demo.py
- Output:
multi-sheet-sales-demo-output.xlsxwith sheetsSummary,Raw Data,Pipeline, andGlossary, demonstrating tables, stacks, spacing, and utility styles.
Types & ergonomics
- Modern Python with full type hints.
- Pure Python stack traces; easy to debug, script, and test.
- Deterministic rendering for stable diffs in CI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xpyxl-0.1.0.tar.gz.
File metadata
- Download URL: xpyxl-0.1.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33a2ec7ed59e19737e6f6e1c6850774991f9dcd78153d02eb84b51f4d3d6975b
|
|
| MD5 |
7fc75665a5c14bd8d7725234027ac74d
|
|
| BLAKE2b-256 |
688c7868fe5f2850e7d89356e059d4bcfb920c430e158857d885337560ec2965
|
Provenance
The following attestation bundles were made for xpyxl-0.1.0.tar.gz:
Publisher:
publish.yml on dakixr/xpyxl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xpyxl-0.1.0.tar.gz -
Subject digest:
33a2ec7ed59e19737e6f6e1c6850774991f9dcd78153d02eb84b51f4d3d6975b - Sigstore transparency entry: 592388646
- Sigstore integration time:
-
Permalink:
dakixr/xpyxl@3df7adae1c9adda4e08917a2913685da7ee9b025 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/dakixr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3df7adae1c9adda4e08917a2913685da7ee9b025 -
Trigger Event:
push
-
Statement type:
File details
Details for the file xpyxl-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xpyxl-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c682af5c28ad40d489124a99707ed8959211fdb590d29b8b553d6c7c82e3cb5
|
|
| MD5 |
62a8f837b706e9f36de3aae74df98371
|
|
| BLAKE2b-256 |
6cb82d3f762ed4568fcf03b80c5cb3d1d7e79161152ebfdba2aa3ee07b427182
|
Provenance
The following attestation bundles were made for xpyxl-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on dakixr/xpyxl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xpyxl-0.1.0-py3-none-any.whl -
Subject digest:
1c682af5c28ad40d489124a99707ed8959211fdb590d29b8b553d6c7c82e3cb5 - Sigstore transparency entry: 592388651
- Sigstore integration time:
-
Permalink:
dakixr/xpyxl@3df7adae1c9adda4e08917a2913685da7ee9b025 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/dakixr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3df7adae1c9adda4e08917a2913685da7ee9b025 -
Trigger Event:
push
-
Statement type: