flowchart TD
A[ExcelAlchemy Facade]
A --> B[ExcelSchemaLayout]
A --> C[ExcelHeaderParser]
A --> D[ExcelHeaderValidator]
A --> E[RowAggregator]
A --> F[ImportExecutor]
A --> G[ExcelRenderer]
A --> H[ExcelStorage]
B --> I[FieldMeta / FieldMetaInfo]
F --> J[Pydantic Adapter]
G --> K[writer.py]
H --> L[MinioStorageGateway]
H --> M[Custom Storage]
G --> N[i18n Display Messages]
F --> O[Runtime Messages]
flowchart LR
A[Pydantic model + FieldMeta] --> B[ExcelAlchemy facade]
B --> C[ExcelSchemaLayout]
B --> D[ExcelHeaderParser / Validator]
B --> E[RowAggregator]
B --> F[ImportExecutor]
B --> G[ExcelRenderer]
B --> H[ExcelStorage]
G --> I[Workbook output]
F --> J[Import result workbook]
src/excelalchemy/core/alchemy.py
- owns the user-facing workflow
- coordinates import/export operations
- keeps the top-level API compact
src/excelalchemy/core/schema.py
- extracts Excel-facing layout from models
- expands composite fields
- validates ordering assumptions
src/excelalchemy/core/headers.py
- parses simple and merged headers
- validates workbook header rows against schema layout
src/excelalchemy/core/rows.py
- aggregates flattened worksheet rows back into model-shaped payloads
- maps row/cell errors back into workbook coordinates
src/excelalchemy/core/executor.py
- validates row payloads
- dispatches create/update/upsert logic
- isolates backend execution from parsing concerns
src/excelalchemy/core/rendering.py
src/excelalchemy/core/writer.py
- turns worksheet tables into workbook payloads
- applies comments, colors, result columns, and workbook hint text
src/excelalchemy/core/storage_protocol.py
src/excelalchemy/core/storage.py
src/excelalchemy/core/storage_minio.py
- defines a stable storage contract
- resolves configured storage strategy
- ships one built-in Minio implementation
src/excelalchemy/metadata.py
- exposes
FieldMeta(...)/ExcelMeta(...)as the stable public entry points - keeps
FieldMetaInfoas a compatibility facade for the 2.x line - splits the real metadata state into declaration, runtime binding, workbook presentation, and import-constraint layers
- keeps runtime metadata separate from validation backend internals
src/excelalchemy/helper/pydantic.py
- adapts Pydantic models to ExcelAlchemy needs
- shields the rest of the codebase from version-specific framework details
src/excelalchemy/i18n/messages.py
- separates runtime errors from workbook display text
- provides locale-aware workbook-facing messages
Implement ExcelStorage when you want a different backend.
Implement a new ExcelFieldCodec or CompositeExcelFieldCodec when you want custom workbook semantics.
Built-in field annotations keep concise aliases like Email and DateRange, while the *Codec names expose the adapter role more explicitly.
Both declaration styles are supported:
FieldMeta(...)as the concise compatibility-friendly syntax sugarAnnotated[T, Field(...), ExcelMeta(...)]as the more explicit Pydantic v2-first style
Use data_converter when the workbook schema should not map 1:1 to backend payloads.
Use locale='zh-CN' | 'en' to control workbook-facing display text without changing runtime exception language.
src/excelalchemy/codecs/: built-in Excel field codecs and codec base abstractionssrc/excelalchemy/metadata.py: Excel-specific field metadata and declaration helperssrc/excelalchemy/config.py: importer/exporter configuration modelssrc/excelalchemy/exceptions.py: public exception typessrc/excelalchemy/_primitives/identity.py: private typed string and index wrappers used across the core layersrc/excelalchemy/_primitives/constants.py: private constant and enum definitionssrc/excelalchemy/results.py: import/export result modelssrc/excelalchemy/_primitives/header_models.py: private workbook header model objectssrc/excelalchemy/_primitives/deprecation.py: private deprecation helpers used by compatibility shimssrc/excelalchemy/types/: compatibility import layer for pre-refactor pathssrc/excelalchemy/exc.py,src/excelalchemy/identity.py,src/excelalchemy/header_models.py,src/excelalchemy/const.py: compatibility or low-level facade modules kept at the package root
Compatibility policy:
excelalchemy.types.*andexcelalchemy.types.value.*remain available throughout the 2.x line- those imports emit
ExcelAlchemyDeprecationWarningat import time - the compatibility layer is scheduled for removal in ExcelAlchemy 3.0
excelalchemy.excnow points to the publicexcelalchemy.exceptionsmoduleexcelalchemy.identityandexcelalchemy.header_modelsremain as 2.x compatibility imports; prefer the package root or internal modules only
The codebase is designed around stable seams:
- facade vs collaborators
- metadata vs validation backend
- storage protocol vs concrete storage
- workbook display text vs runtime messages
Those seams are what made the later migrations possible without rewriting the whole project.