How soxhub/openpyxl works
Project type and purpose
• Type: A standalone, full-featured Python library (not a web or mobile app).
• Purpose: Read, manipulate and write Microsoft Office Open XML spreadsheets (xlsx/xlsm/xltx/xltm) entirely in Python. It provides a high-level API (Workbook, Worksheet, Cell…) plus low-level XML, packaging and rendering services to produce a valid .xlsx file or parse an existing one.
File structure
• Top-level directories and files
– setup.py, setup.cfg, requirements.txt, tox.ini, pytest.ini: Build, packaging and CI configuration.
– openpyxl/: The entire implementation lives here, structured into subpackages by feature.
– doc/: User and developer documentation (Sphinx) including tutorials and API reference.
– tests (embedded under each subpackage and conftest.py at root): Unit and integration tests.
• Key subpackages inside openpyxl/
– workbook, worksheet, cell: Core data model classes (Workbook, Worksheet, Cell, RichText).
– reader, writer: File I/O layers that parse XML and produce XML.
– xml: Shared XML utility functions and constants.
– packaging: ZIP-container abstraction (part, relationships, manifest).
– chart, chartsheet, drawing: Domain features for charts and drawings.
– formatting, styles: Styling and formatting rule engines.
– formula, filters, comments, pivot: Advanced spreadsheet features.
– descriptors: Meta-programming layer for attribute serialization.
– utils, compat: Utility functions and compatibility shims.
• Patterns and architecture
– Layered architecture: Public API → Data Model → Service layers (reader/writer/xml) → Infrastructure (packaging, stdlib zip).
– Serialization/deserialization pattern: Each data object is serialisable via descriptors and reader/writer engines.
README for additional insights
• Confirms that openpyxl is a pure-Python library for OOXML spreadsheets.
• Mentions optional dependency on defusedxml for XML-attacks mitigation.
• Sample code shows the public-facing API (Workbook, Worksheet, save).
Elements
– load_workbook → Reader → Data Model → Public API
– Workbook.save → Writer → Packaging → .xlsx file
– Another for feature modules (Charts, Drawing, Formatting)
– A separate style for external dependencies (defusedxml) and for tests/docs
Detail
• Major subpackage is represented so that future maintainers immediately see where to add new features.
• Flow of responsibility: who owns XML parsing, who constructs relationships, who renders drawing parts, and how the data model lives independently from file I/O.
• Don’t just list modules—show how they collaborate in both the load and save paths.