# Using xlspy

[Home](<https://justybase.github.io/xlspy/index.md>) · [Runnable examples](<https://github.com/justybase/xlspy/blob/main/examples/README.md>) · [Benchmarks](<https://justybase.github.io/xlspy/benchmarks/index.md>)

Read, write, and update Excel workbooks from Python. This guide covers the APIs and options behind the [first workbook](<https://justybase.github.io/xlspy/learn/first-workbook/index.md>).

The guide is split by task:

- [Writing workbooks](<https://justybase.github.io/xlspy/guide/writing/index.md>): XlsbWriter and XlsxWriter: sheets, options, large exports, text rules, failures and errors.
- [Formatting and layout](<https://justybase.github.io/xlspy/guide/styling/index.md>): Number and date formats, cell styles, column widths, sheet view, headers, conditional formats, tables and row/column groups.
- [Formulas, charts and other objects](<https://justybase.github.io/xlspy/guide/objects/index.md>): Formulas, validation, hyperlinks, images, printing, charts, sparklines, slicers, shapes, rich text, document properties, pivot tables, comments and template metadata.
- [pandas and polars DataFrames](<https://justybase.github.io/xlspy/guide/dataframes/index.md>): to\_xlsx, to\_xlsb and write\_dataframe.
- [Updating existing workbooks](<https://justybase.github.io/xlspy/guide/updating/index.md>): XlsxUpdater, XlsmUpdater and XlsbUpdater.
- [Reading workbooks](<https://justybase.github.io/xlspy/guide/reading/index.md>): ExcelReader and the read modes.
- [The workbook model](<https://justybase.github.io/xlspy/guide/model/index.md>): load\_workbook and Workbook: the openpyxl-like model, loaded XLSX and XLSB workbooks, read-only mode.

The [API reference](<https://justybase.github.io/xlspy/api/index.md>) 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.
