xlwt
A pure-Python library for writing legacy Microsoft Excel (.xls) spreadsheet files.
Repository Health
Technical Analysis
xlwt is a pure-Python library that generates spreadsheet files in the legacy Microsoft Excel BIFF format (.xls), compatible with Excel versions 95 through 2003. It lets developers create workbooks and worksheets, write cell values of various types, and apply rich formatting — fonts, colors, borders, number formats, column widths, and cell styles — entirely from Python with no dependencies outside the standard library.
A descendant of the pyExcelerator project, xlwt was for years the standard tool for producing .xls files from Python, widely used for reporting, data export, and integration with older systems and templates that require the classic binary Excel format rather than the newer .xlsx.
What You Get
- A
Workbook/WorksheetAPI for constructing multi-sheet .xls files - Cell writing for strings, numbers, dates, booleans, and formulas
- Rich formatting via
easyxfandXFStyle: fonts, colors, borders, alignment, number formats - Column-width, row-height, and merged-cell control
- A pure-Python implementation with no dependencies beyond the standard library
Common Use Cases
- Exporting reports and datasets to legacy .xls files consumable by Excel 97-2003
- Generating formatted spreadsheets from database query results
- Producing .xls output for older enterprise systems that reject .xlsx
- Filling styled templates programmatically for financial or business reporting
Under The Hood
Architecture - The xlwt package models the Excel BIFF file format directly: high-level classes (Workbook, Worksheet, Row, Cell, Column) sit over low-level record writers in BIFFRecords.py, and output is assembled into an OLE2 compound document via CompoundDoc.py. Styling flows through Style.py/Formatting.py (fonts, borders, patterns, number formats) and formulas are compiled by an ANTLR-generated parser (ExcelFormula.py, excel-formula.g) into BIFF token streams.
Tech Stack - Pure Python targeting Python 2.7 and 3.4+, with no runtime dependencies outside the standard library. Packaging uses setuptools; testing is configured through tox and a tests/ directory.
Code Quality - The codebase is mature and stable with a tests/ suite and historical CI (Travis/Coveralls badges). Module and class naming reflects the underlying Excel record model rather than modern Python style, and the project is in maintenance mode, but behavior is well established and battle-tested across years of production use.
API Design - The public API is approachable: create a Workbook, call add_sheet, then write(row, col, value, style). Styles are built with the concise easyxf string DSL or the more explicit XFStyle objects. The README’s quick-start gets a formatted, multi-type spreadsheet written in a dozen lines, so onboarding is fast despite the dated internals.
Used by 3 apps in this directory
Agno
Devops · AI Development · Automation
Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.
MaxKB
AI Development · Knowledge Management
Build enterprise-grade AI agents with RAG, workflows & multi-modal support
Odoo
ERP · CRM · Productivity
The open source ERP platform that integrates CRM, accounting, inventory, manufacturing, and 60+ business apps into one seamlessly connected suite.