Skip to content

Excel reports. Python simplicity.

Turn Python data into Excel workbooks — from everyday reports to large exports. Read and write XLSB and XLSX, export DataFrames, and refresh existing XLSM templates while preserving their macros.

PyPI Python versions MIT license CI

pip install xlspy

Why xlspy

Fast by default

2.5 million cells in under a second as XLSB. The native Rust extension accelerates reads, writes and load_workbook().

XLSB and XLSX

One API for both formats: XlsxWriter and XlsbWriter take the same rows, styles, charts and tables.

DataFrames included

Export pandas or polars directly with to_xlsx() / to_xlsb(), or stream rows from a database cursor.

Templates preserved

Refresh data in XLSM templates without touching the VBA project, drawings or unrelated sheets.

No required dependencies

The core library has no required Python packages. Pandas and polars are optional extras.

Excel not required

Create and read workbooks on Linux, Windows or macOS. Microsoft Excel is not needed for the core APIs.

Your first report

from xlspy import F, Style, XlsxWriter

rows = [
    ["Product", "Units", "Revenue"],
    ["Coffee", 120, (12500, F.THOUSANDS_SEP)],
    ["Tea", 90, (8400, F.THOUSANDS_SEP)],
    ["Juice", 45, (5100, F.THOUSANDS_SEP)],
]

with XlsxWriter("sales.xlsx") as workbook:
    workbook.add_sheet("Sales")
    workbook.write_sheet(
        rows,
        header_style=Style(bold=True, fill="#183C52", font_color="#FFFFFF"),
        freeze_panes="A2",
    )

For binary output, change XlsxWriter to XlsbWriter and the filename to .xlsb. The rest of the code stays the same.

Build this report step by step →

Performance at a glance

50,000 × 50 cells (2.5 million cells), Windows 11, AMD Ryzen 7 7840HS:

xlspy XLSB xlspy XLSX xlsxwriter openpyxl
Write 0.67 s 1.16 s 11.71 s 20.39 s
Read 0.22 s 0.98 s — 14.35 s

Full benchmarks and methodology →

Start here

Learn xlspy

A ten-step tutorial: install, write your first workbook, style it, add formulas and charts, read it back.

How-to guides

Task-focused pages: choose a format, stream large exports, update templates, add pivots, comments and protection.

API reference

Every public class and function, generated from the docstrings, with signatures and examples.

Explanation

Architecture, performance, validation and the openpyxl parity matrix — the reasoning behind the library.

Works with your stack

Workflow Entry point
pandas or polars to_xlsx(df, "report.xlsx"), to_xlsb(df, "report.xlsb")
Existing Excel template XlsxUpdater, XlsmUpdater, XlsbUpdater
Database cursor writer.write_sheet(cursor_rows(cursor))
Random access and edits load_workbook(path)
Values only, fastest ExcelReader(path).get_rows(sheet)

Examples · Changelog · GitHub