Skip to main content

Composable framework for building styled Excel reports with openpyxl and matplotlib.

Project description

xllayout

Composable framework to build styled Excel reports with openpyxl and matplotlib.

Philosophy

xllayout is split into three layers:

  1. Theme: centralized visual tokens (fonts, fills, borders, number formats, spacing).
  2. Components: reusable blocks (TitleBlock, KpiCard, TableBlock, MatplotlibChart, etc.).
  3. Layouts: sheet composition using absolute canvas coordinates or Grid12.

This lets you place components at any coordinate without relying on cursor-based writing.

Structure

xllayout/
  pyproject.toml
  xllayout/
    __init__.py
    core/
      canvas.py
      grid.py
      theme.py
      formats.py
      utils.py
    components/
      title.py
      text.py
      section.py
      kpi.py
      table.py
      chart.py
    layouts/
      summary.py
    writer/
      workbook.py
  examples/
    build_summary.py

Install

Editable (recommended for development):

pip install -e ".[charts]"

Standard install:

pip install ".[charts]"
  • Base dependency: openpyxl
  • Optional extra charts: matplotlib, Pillow

Quick API

from xllayout.core.theme import LightTheme
from xllayout.layouts.summary import ExecutiveSummaryData
from xllayout.writer.workbook import ReportWriter

writer = ReportWriter(theme=LightTheme(), detect_collisions=True)
wb = writer.new_workbook()
writer.build_summary_sheet(wb, data)  # data: ExecutiveSummaryData
wb.save("report.xlsx")

Canvas vs Grid12

Absolute placement:

from xllayout.core.canvas import SheetCanvas

canvas = SheetCanvas(ws, theme, detect_collisions=True)
canvas.put(component, row=5, col=3)

Grid placement:

from xllayout.core.grid import Grid12

grid = Grid12(canvas)  # 12 tracks
grid.put(component, y=4, x=1, w=6, h=5)

If detect_collisions=True, overlapping components raise ValueError.

Build a New Layout

  1. Create a typed input dataclass under layouts/.
  2. In build(ws), initialize SheetCanvas and optionally Grid12.
  3. Place components with canvas.put(...) or grid.put(...).
  4. Expose a facade method in ReportWriter.

Run the example

python examples/build_summary.py

Output:

examples/output/summary_report_example.xlsx

Versioning and publishing

  • Uses SemVer (1.0.0, 1.0.1, 1.1.0, ...).
  • Recommended for teams: publish to a private PyPI-compatible registry.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xllayout-1.0.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xllayout-1.0.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file xllayout-1.0.0.tar.gz.

File metadata

  • Download URL: xllayout-1.0.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for xllayout-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c35ad7d25df7e0a205bf690921bdc950d343e78c60024c42dfc1f746ba75f469
MD5 0a4cc10bf35aca91fd8668582c60f2b5
BLAKE2b-256 39a0d55ca1412214af30708ca7b204dd6f8329131f1ad4d4a694be7720e7e60e

See more details on using hashes here.

File details

Details for the file xllayout-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: xllayout-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for xllayout-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 38a1fdc9bd1f032ae093b3a05d1d2019dbdf5e08a6daf16a0acc86a1201eec6b
MD5 3a0311dc0d54718fd43a6686fe9b8d6c
BLAKE2b-256 d4ed2c4fce516c8fcf95a511ca2e341d7af1ab2aee44914a6cf13772c4474403

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page