Skip to content

Learn xlspy

This tutorial takes you from an empty Python file to a polished, automated Excel report. Each lesson is short, runnable, and builds on the previous one.

1. Installation

Install xlspy, verify the native extension, and pick the optional extras.

2. Your first workbook

Write a styled XLSX report with headers, number formats and frozen panes.

3. XLSB in one line

Switch the same report to binary XLSB without changing the API.

4. Styles and number formats

Apply colors, borders, alignment, column widths and per-cell styles.

5. Formulas, tables and charts

Add formulas, an Excel table, data validation and a chart.

6. DataFrames

Export pandas and polars data, with formats and missing values.

7. Reading a workbook

Stream values with ExcelReader or load an editable model.

8. Updating a template

Replace a template's data while keeping its styles, sheets and macros.

9. Streaming a large export

Write millions of rows from a generator with bounded memory.

10. Next steps

Where to go after the tutorial: how-to guides, reference and examples.

Before you start

You need Python 3.11 or newer. Microsoft Excel is not required. If you want to run the DataFrame lesson, install pandas or polars as well.

python --version
pip install xlspy

Every lesson runs from a normal Python script. Commands are shown for a shell; use PowerShell on Windows if you prefer.

Follow along in a scratch directory

Create an empty folder, save each lesson as lesson.py, and run it with python lesson.py. The files the lesson creates appear next to it.

Start with installation →