xlwt

A pure-Python library for writing legacy Microsoft Excel (.xls) spreadsheet files.

Library
PyPI
v1.3.0
1,044stars
BSD

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
38/100Needs Attention
Development Activity0
Maintenance0
Community64
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
64/100Good
Architecture60
Code Quality62
Innovation55
Learning Curve78

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/Worksheet API for constructing multi-sheet .xls files
  • Cell writing for strings, numbers, dates, booleans, and formulas
  • Rich formatting via easyxf and XFStyle: 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.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search