Skip to main content

EzXl

PyPI version Python versions PyPI status License CI Docs uv linter type checker

Logo

EzXl is a lightweight Python library for Excel automation via COM (win32com) on Windows — open workbooks, manipulate sheets, interact with the ribbon, and convert between formats, all from a clean Python API.

📦 Installation

Standard

# Create and activate a virtual environment
python -m venv .venv
.venv\Scripts\activate

# Install in development mode with the `dev` dependency group
uv sync --group dev

pywin32 post-install step (mandatory)

Warning: pywin32 requires a post-install script to register COM components. This step is mandatory and must be run once after installation. Skipping it will cause COM dispatch to fail.

python .venv/Scripts/pywin32_postinstall.py -install

Corporate offline environment

In restricted environments without PyPI access, install from local wheel files only. No network requests are made during installation. Configure your pip to point to a local wheel directory:

pip install --no-index --find-links=\\share\wheels -e . --group dev

Optional pywinauto backend

To enable the pywinauto GUI automation backend (UIA-based, locale-independent):

pip install -e ".[pywinauto]"

Note: Ensure your Python interpreter bitness (32-bit or 64-bit) matches the installed Excel. COM dispatch will fail on a mismatch. Verify with:

python -c "import struct; print(struct.calcsize('P') * 8)"

🚀 Quick Start

from ezxl import ExcelApp

# Open a workbook and read from a sheet
with ExcelApp(mode="dispatch", visible=True) as xl:
    wb = xl.open("C:/reports/budget.xlsx")
    sheet = wb.sheet("Summary")
    value = sheet.cell("B2").value
    print(value)
    wb.save()

# Attach to a running Excel instance (left running on exit)
with ExcelApp(mode="attach") as xl:
    xl.gui.ribbon.execute("FileSave")

# Attach if Excel is open, start a private instance otherwise.
# Excel is only quit on exit when ezxl started it.
with ExcelApp(mode="auto") as xl:
    wb = xl.workbook()

🎯 Key Features

  • ✅ COM Automation: open, attach, navigate Excel via win32com
  • ✅ GUI Interaction: ribbon, menus, dialogs, and SendKeys via win32com
  • ✅ Swappable GUI Backends: COM or pywinauto, injected via protocol ABCs
  • ✅ File I/O: xlsx↔csv conversion via polars+fastexcel (no Excel required)
  • ✅ Closed-file Formatting: colors, fonts, and borders via openpyxl
  • ✅ Thread Safety: COM STA model enforced, thread identity checked at construction
  • ✅ Full Type Hints: complete typing for IDEs and linters
  • ✅ Corporate Ready: offline wheel install, proxy support

📚 Documentation

Full documentation is available online: neuraaak.github.io/ezxl

🧪 Testing

# Install dev dependencies
uv sync --group dev

# Run unit tests (no Excel required) - what CI runs
uv run poe test-ci

# Run the whole suite, integration tests included (requires local Excel)
uv run poe test

Note: Integration tests marked with @pytest.mark.excel require a locally installed Excel instance. They are excluded from CI/CD pipelines and are intended for local verification only.

🛠️ Development Setup

# Clone the repository
git clone https://github.com/neuraaak/ezxl.git
cd ezxl

# Create and activate a virtual environment
python -m venv .venv
.venv\Scripts\activate

# Install in development mode with all dev dependencies
uv sync --group dev

# Mandatory: register pywin32 COM components
python .venv/Scripts/pywin32_postinstall.py -install

# Set up git hooks
git config core.hooksPath .hooks

See the Development Guide for detailed setup instructions.

🔌 API Overview

🖥️ COM Automation (5)

Symbol Description
ExcelApp COM session — dispatch or attach, context manager
WorkbookProxy Workbook open/save/close, sheet access
SheetProxy Sheet navigation, cell access
CellProxy Single cell read/write
RangeProxy Range selection and bulk operations

🎛️ GUI Interaction (4)

Symbol Description
GUIProxy Unified GUI facade with swappable backends
RibbonProxy Ribbon execution and state via COM
MenuProxy Legacy CommandBar traversal via COM
DialogProxy File pickers and alerts via COM

🔌 GUI Backends — pywinauto (4)

Symbol Description
PywinautoRibbonBackend Ribbon via keyboard shortcuts (locale-independent)
PywinautoMenuBackend Menu traversal via UIA
PywinautoDialogBackend File pickers via UIA + Win32
PywinautoKeysBackend Keystroke injection via pywinauto

📂 File I/O (5)

Symbol Description
read_excel Read xlsx into a polars DataFrame
read_csv Read csv into a polars DataFrame
xlsx_to_csv Convert xlsx to csv (no Excel required)
csv_to_xlsx Convert csv to xlsx (no Excel required)
ExcelFormatter Closed-file formatting (colors, fonts, borders)

📦 Dependencies

  • pywin32>=306 — COM driver (win32com.client), Windows-only
  • polars>=1.0.0 — DataFrame I/O engine
  • fastexcel>=0.11.0 — Fast xlsx reader (Rust binding)
  • xlsxwriter>=3.0.0 — xlsx write backend for polars
  • openpyxl>=3.1.0 — Closed-file formatting
  • ezplog>=2.4.0,<3.0.0 — Structured logging
  • typer>=0.29.3 — Command-line interface

Optional:

  • pywinauto>=0.6.8 — UI Automation backend (locale-independent GUI interaction)

📄 License

MIT License – See LICENSE file for details.


ezxl — Excel automation made simple, reliable, and Pythonic. 🐍

Metadata

Release files for ezxl 1.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ezxl 1.5.1
File Size Uploaded Provenance Actions
ezxl-1.5.1.tar.gz 154.9 kB Without provenance Details for ezxl-1.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ezxl 1.5.1
File Interpreter ABI Platform Actions
ezxl-1.5.1-py3-none-any.whl Python 3 none any Details for ezxl-1.5.1-py3-none-any.whl

Total release size: 225.8 kB

Release files / ezxl-1.5.1.tar.gz

Download URL ezxl-1.5.1.tar.gz
Size 154.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c073b981bd52a46aa9b0cc2ebe4c0861f0c039bc9153d82d088c10561dc33afc
BLAKE2b-256 checksum
How to use checksums
919fb8c2b6f6e069259c6dbe4b577e022fae943f6544a6be5d25bb66a0269514
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ezxl-1.5.1-py3-none-any.whl

Download URL ezxl-1.5.1-py3-none-any.whl
Size 70.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1d6d0e94e712cb610b1fb3882aa6f90e6d508a9e57bc5fb835fb7581448075e
BLAKE2b-256 checksum
How to use checksums
75f4453ef7f98bbe23e344d4a189229404edf2d4c6c381ba4898f1e5131feca0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Security for ezxl 1.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page