Skip to main content

Schema-driven Python library for typed Excel import/export workflows with Pydantic and locale-aware workbooks.

Project description

ExcelAlchemy

Schema-driven Python library for typed Excel import/export workflows with Pydantic and locale-aware workbooks.

ExcelAlchemy turns Pydantic models into workbook contracts:

  • generate Excel templates from code
  • validate uploaded workbooks
  • map failures back to rows and cells
  • return result workbooks and API-friendly error payloads
  • keep workbook IO pluggable through ExcelStorage

The current stable release is ExcelAlchemy 3.0. It uses ordinary Python annotations plus explicit ExcelColumn(...) metadata. Old 2.x field factories, compatibility imports, legacy config fields, and facade aliases are not current API.

GitHub Repository · Full README · Getting Started · Examples · Public API · Migration Notes

Screenshots

Template

Excel template screenshot

Import Result

Excel import result screenshot

Install

pip install ExcelAlchemy

Optional Minio-compatible storage support:

pip install "ExcelAlchemy[minio]"

Quick Example

from typing import Annotated

from pydantic import BaseModel, Field

from excelalchemy import EmailCodec, ExcelAlchemy, ExcelColumn, ImporterConfig


class EmployeeImport(BaseModel):
    name: Annotated[str, ExcelColumn(label='Name', order=1)]
    email: Annotated[
        str,
        Field(min_length=8),
        ExcelColumn(
            label='Email',
            codec=EmailCodec(),
            order=2,
            hint='Use your work email',
            example_value='alice@company.com',
        ),
    ]


alchemy = ExcelAlchemy(ImporterConfig(EmployeeImport, locale='en'))
template = alchemy.download_template_artifact(filename='employees-template.xlsx')

excel_bytes = template.as_bytes()

Import Workflow

The shortest import path is:

template -> preflight -> import -> remediation -> delivery

Minimal backend sketch:

from excelalchemy.results import ImportLifecycleEvent, build_frontend_remediation_payload


events: list[ImportLifecycleEvent] = []

preflight = alchemy.preflight_import('employees.xlsx')
if preflight.is_valid:
    result = await alchemy.import_data(
        'employees.xlsx',
        'employees-result.xlsx',
        on_event=events.append,
    )
    payload = {
        'result': result.to_api_payload(),
        'cell_errors': alchemy.cell_error_map.to_api_payload(),
        'row_errors': alchemy.row_error_map.to_api_payload(),
        'remediation': build_frontend_remediation_payload(
            result=result,
            cell_error_map=alchemy.cell_error_map,
            row_error_map=alchemy.row_error_map,
        ),
    }

Why ExcelAlchemy

  • Pydantic v2-based schema extraction and validation
  • Annotated[..., ExcelColumn(...)] declaration style
  • workbook comments and result workbooks in zh-CN, en, or ja
  • pluggable storage instead of a hard-coded backend
  • openpyxl-based runtime path without pandas
  • contract tests, Ruff, and Pyright in the development workflow

Learn More

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

excelalchemy-3.0.0.tar.gz (74.3 kB view details)

Uploaded Source

Built Distribution

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

excelalchemy-3.0.0-py3-none-any.whl (102.1 kB view details)

Uploaded Python 3

File details

Details for the file excelalchemy-3.0.0.tar.gz.

File metadata

  • Download URL: excelalchemy-3.0.0.tar.gz
  • Upload date:
  • Size: 74.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for excelalchemy-3.0.0.tar.gz
Algorithm Hash digest
SHA256 2860cd33113fb89691e45376472d2b6596485bfba9f652f44c83c27f2b0537e7
MD5 0f6776970289d972cf59b1ba4a6badc8
BLAKE2b-256 260e21e67366f1a9c36962801448be937286e9ac93a028dc92c679e2c121ee62

See more details on using hashes here.

Provenance

The following attestation bundles were made for excelalchemy-3.0.0.tar.gz:

Publisher: python-publish.yml on RayCarterLab/ExcelAlchemy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file excelalchemy-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: excelalchemy-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 102.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for excelalchemy-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be816b5b9f8705e583aa11c7eb33ac2a18ce15e471a9bda462e869ebc06876b2
MD5 369a03545eb892e60bc12f959b2529ba
BLAKE2b-256 9d9903c663bea68be5bdeb6bc6364075866bb34dd2aa635b6f2ee243ef0632fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for excelalchemy-3.0.0-py3-none-any.whl:

Publisher: python-publish.yml on RayCarterLab/ExcelAlchemy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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