Skip to main content

A short description of ezxl

Project description

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
pip install -e ".[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 ".[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
with ExcelApp(mode="attach") as xl:
    xl.gui.ribbon.execute("FileSave")

🎯 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
pip install -e ".[dev]"

# Run unit tests (no Excel required)
pytest tests/ -m "not excel"

# Run integration tests (requires local Excel)
pytest tests/ -m excel

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
pip install -e ".[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.0.0 — Structured logging

Optional:

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

📄 License

MIT License – See LICENSE file for details.

🔗 Links


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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ezxl-1.0.1.tar.gz (189.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ezxl-1.0.1-py3-none-any.whl (61.4 kB view details)

Uploaded Python 3

File details

Details for the file ezxl-1.0.1.tar.gz.

File metadata

  • Download URL: ezxl-1.0.1.tar.gz
  • Upload date:
  • Size: 189.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ezxl-1.0.1.tar.gz
Algorithm Hash digest
SHA256 bd04c32723a295c1f200c95ee42083b8b200660ab18d63e85674ccde23a22651
MD5 902681f537287d062025f73bf83e03e2
BLAKE2b-256 ea5de3d96971f4415dd96a4bcd30f08d8284f5efdc6626bd35650eda60c5a32d

See more details on using hashes here.

File details

Details for the file ezxl-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ezxl-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 61.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ezxl-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3fffa4c987a24015e264e19fe27ba3fae195b7487f79d5e15222ac5f53e6a330
MD5 e8c6b74ca5641fe8ddebc8e7060ed6ed
BLAKE2b-256 d300d4c9f77c261ae332ca23e2d3594f05c16b87ed703e478d0cac6d03ba39ed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page