Metadata-Version: 2.5
Name: xlio
Version: 0.7.0
Summary: Internal xlsx reader and writer of the sheetmill project, extracted from xlrecalc; not intended for direct use.
Project-URL: Homepage, https://github.com/sheetmill/xlio
Project-URL: Documentation, https://xlio.readthedocs.io
Project-URL: Source, https://github.com/sheetmill/xlio
Project-URL: Changelog, https://github.com/sheetmill/xlio/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/sheetmill/xlio/issues
Author: Ethan Post
License-Expression: MIT AND LicenseRef-Ecma-Text-Copyright-Policy
License-File: LICENSE
License-File: NOTICE
Keywords: excel,ooxml,reader,spreadsheet,writer,xlsm,xlsx
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Office/Business :: Financial :: Spreadsheet
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown

# xlio

**xlio is an internal package of the sheetmill project.** It reads xlsx files as Excel reads
them and changes their cells without disturbing anything else. It was extracted from
[xlrecalc](https://github.com/sheetmill/xlrecalc), whose own reader and writer it began as, to be
shared by the sheetmill packages. It is not intended for direct use: its API may change in any
minor release without the deprecation period the public sheetmill packages give, while patch
releases only fix bugs and keep the API. If you depend on it anyway, pin a minor version (for
example `xlio==0.7.*`).

It is written in pure Python with the standard library only. The reader checks a package before
it parses anything (part count and sizes, compression methods, encryption, names used twice, a
DTD in any part) and refuses what Excel refuses; the writer copies every part it does not change
byte for byte and rewrites only the cells it is given.

Which Excel it follows: `read_csv` reads a CSV file as Excel for Windows opens it, unless it is
given `platform="mac"`, which reads it as Excel for Mac does; `read_fixed_width` reads fixed-width
text as Excel opens it, the same on both platforms. Both rest on results captured from Excel under
Microsoft 365. The readings of xlsx files (`open`, `check`) take no platform: they were captured
from Excel 16 for Mac, and most are not yet verified on Windows. Those captured on both platforms
gave the same results: error values (each error's text and `ERROR.TYPE`), how a conditional format's
base rule joins its extension rule, the refusal of a sheet with two conditional-formatting
extensions, and where a group shape's members are drawn (but for a group with a zero child extent,
which xlio leaves unplaced). A cell font's size is read as Excel for Windows holds it, not yet
verified on the Mac. The files `patch` writes with the newer errors and with formulas marked for
recalculation open in Excel on both platforms without a repair.

xlio is part of the [sheetmill](https://github.com/sheetmill) project, with
[xlformat](https://github.com/sheetmill/xlformat), which applies Excel number formats,
[xlrecalc](https://github.com/sheetmill/xlrecalc), which recalculates workbooks, and
[sheetpeek](https://github.com/sheetmill/sheetpeek), which shows workbooks as Excel does.

## What it covers

- `open` reads a workbook lazily: its sheets' cells (values typed as Excel reads them, formulas,
  rich values behind the cells), styles and theme, tables, conditional formats, views, print
  settings, calculation settings, the drawing (pictures with their outline and effects, shapes,
  charts' frames, group shapes with their members, each with its box in its group's), notes and
  threaded comments, and every element it does not model, listed. `check` tells whether Excel
  would open a file without a repair.
- `patch` changes cells, cached results and array fills and copies everything else byte for
  byte; it writes each error as Excel writes it (the newer ones as `#VALUE!` with a rich value),
  can mark formula cells for Excel to recalculate (`recalculate=`) and can ask Excel to
  recalculate every formula on opening.
- `read_csv` and `read_fixed_width` read CSV and fixed-width text into a one-sheet workbook as
  Excel opens such a file: each field converted as Excel converts it (numbers, dates, errors,
  text). `CsvOptions` says how to read a CSV file, `FixedWidthOptions` (its `Field`s) a
  fixed-width one; both are `TextOptions`.

## Files from people you do not trust

Open them with `limits=xlio.ReadLimits.UNTRUSTED`, which bounds what reading one may cost (its
parts, their sizes, its cells, its text). To report a security problem, see
[`SECURITY.md`](https://github.com/sheetmill/xlio/blob/main/SECURITY.md).

## Development

`uv sync --group docs` then `uv run pytest`;
[`CONTRIBUTING.md`](https://github.com/sheetmill/xlio/blob/main/CONTRIBUTING.md)
has the pip route, the full set of checks and the commit conventions.

Most of the code is written with Claude Code, reviewed before each commit and tested against
results captured from Excel; see
[`CONTRIBUTING.md`](https://github.com/sheetmill/xlio/blob/main/CONTRIBUTING.md).

## License

The code is under the MIT license
([`LICENSE`](https://github.com/sheetmill/xlio/blob/main/LICENSE)).
`src/xlio/data/presetTableStyles.xml`, the built-in table and pivot table styles from ECMA-376,
is under Ecma International's text copyright policy, as published by Ecma; see
[`NOTICE`](https://github.com/sheetmill/xlio/blob/main/NOTICE).
