XlsxWriter
A Python module for creating fully-featured Excel XLSX files with charts, formatting, and formulas
Repository Health
Technical Analysis
XlsxWriter is a pure-Python library for generating Excel 2007+ XLSX files from scratch. It produces 100% Excel-compatible spreadsheets covering text, numbers, formulas, hyperlinks, merged cells, defined names, and native Excel charts, and supports Python 3.8+ and PyPy3 using only the standard library — no external dependencies required.
Beyond basic cell writing, it handles advanced worksheet features like autofilters, data validation with dropdown lists, conditional formatting, embedded images in multiple formats, rich multi-format strings, cell comments, textboxes, and VBA macros, plus a memory-optimization mode for writing very large files without exhausting RAM. It also integrates directly with Pandas and Polars as an output engine, making it a common choice for data-export pipelines that need richly formatted Excel output rather than a plain CSV-to-XLSX conversion.
What You Get
- A Workbook/Worksheet API for writing text, numbers, formulas, and hyperlinks with full cell formatting
- Native Excel chart generation (bar, line, pie, scatter, radar, stock, and more)
- Data validation, autofilters, conditional formatting, and defined names
- Image embedding (PNG/JPEG/GIF/BMP/WMF/EMF), textboxes, cell comments, and VBA macro support
- A memory-optimization (constant-memory) mode for writing very large workbooks
- Direct integration as a Pandas/Polars Excel writer engine
Common Use Cases
- Exporting Pandas/Polars DataFrames to richly formatted Excel reports instead of plain CSV
- Generating scheduled business reports with charts, conditional formatting, and branded styling
- Building large data-export files where memory-constant streaming mode avoids excessive RAM use
- Producing Excel templates programmatically for finance, ops, or analytics teams who consume XLSX directly
Under The Hood
Architecture: The library is organized around a Workbook object that owns one or more Worksheet/Chartsheet instances, with dedicated modules for each XLSX subsystem — chart_*.py files per chart type, format.py for cell styling, drawing.py and image.py for embedded media, comments.py, custom.py (custom document properties), and packager.py, which is responsible for assembling all the generated XML parts into the final ZIP-based XLSX container per the OOXML spec. This mirrors the actual internal structure of an XLSX file (a ZIP of XML parts plus relationships/content-type manifests), which is also reflected in contenttypes.py and relationships.py.
Tech Stack: Pure Python (99%+ of the codebase) with zero runtime dependencies, targeting Python 3.8+ and PyPy3. It ships its own XML-writing layer rather than depending on a general-purpose XML library, keeping the install footprint minimal — a deliberate design choice given how often this library is pulled in transitively via Pandas/Polars Excel export.
Code Quality: The project has an unusually large test suite — over 1,280 test files under xlsxwriter/test/ — reflecting the fact that XLSX is a strict binary/XML format where subtle output differences break Excel compatibility, so most tests appear to be golden-file comparisons against known-good XLSX output. With 58 contributors but the vast majority of commits (1,391 of ~1,491 total) from the original author, this is a mature, long-running single-maintainer project (13+ years) with occasional external contributions rather than a broad contributor base.
API Design: The core API is intentionally simple for common cases — workbook.add_worksheet(), worksheet.write(), workbook.close() — with formatting and advanced features layered on via optional add_format()/insert_image()-style calls, so a basic script needs only a few lines while advanced features (charts, validation, VBA) are opt-in and don’t complicate the simple path. Extensive documentation and a working example in the README lower the barrier to entry significantly for a domain (OOXML) that is otherwise quite complex to hand-roll.
Used by 3 apps in this directory
Flowfile
Data Engineering
Visual ETL that compiles to Polars — build pipelines on a canvas, export as standalone Python, and run anywhere without platform lock-in.
Horilla
Human Resources · ERP
Open-source HRMS covering recruitment, attendance, payroll, and biometrics in one self-hosted Django application.
Odoo
ERP · CRM · Productivity
The open source ERP platform that integrates CRM, accounting, inventory, manufacturing, and 60+ business apps into one seamlessly connected suite.