Using xlspy¶
Home · Runnable examples · Benchmarks
Read, write, and update Excel workbooks from Python. This guide covers the APIs and options behind the first workbook.
The guide is split by task:
- Writing workbooks: XlsbWriter and XlsxWriter: sheets, options, large exports, text rules, failures and errors.
- Formatting and layout: Number and date formats, cell styles, column widths, sheet view, headers, conditional formats, tables and row/column groups.
- Formulas, charts and other objects: Formulas, validation, hyperlinks, images, printing, charts, sparklines, slicers, shapes, rich text, document properties, pivot tables, comments and template metadata.
- pandas and polars DataFrames: to_xlsx, to_xlsb and write_dataframe.
- Updating existing workbooks: XlsxUpdater, XlsmUpdater and XlsbUpdater.
- Reading workbooks: ExcelReader and the read modes.
- The workbook model: load_workbook and Workbook: the openpyxl-like model, loaded XLSX and XLSB workbooks, read-only mode.
The API reference lists every public class and function with its arguments.
Command line¶
Installing xlspy puts an xlspy command on the PATH; python -m xlspy works
without installing the script:
xlspy sheets report.xlsx
xlspy inspect report.xlsb --json
xlspy validate report.xlsx
xlspy convert report.xlsx report.xlsb
inspect shows sheet sizes and counts of tables, charts, images, notes and
conversations. validate parses every sheet and exits non-zero on a broken
file. convert rewrites through the workbook model, carrying the objects the
model supports between XLSX and XLSB.
Run commands and examples from the repository root unless stated otherwise.