PHP_XLSXWriter

Lightweight, low-memory PHP library for writing Excel XLSX spreadsheets

Library
Composer
v0.39
1,867stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
52/100Fair
Development Activity0
Maintenance20
Community88
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture74
Code Quality68
Innovation72
Learning Curve88

PHP_XLSXWriter is a lightweight PHP library for generating Office 2007+ Excel (.xlsx) spreadsheets with minimal memory usage. It streams output row by row, so it can produce spreadsheets with hundreds of thousands of rows without exhausting PHP’s memory the way heavier libraries like PHPExcel/PhpSpreadsheet can.

With a tiny, dependency-free API you can write multiple worksheets, apply currency, date, and numeric cell formats, add simple formulas, and stream files or strings directly to output. It targets PHP 5.2.1+ and takes UTF-8 encoded input.

What You Get

  • A single-class API (XLSXWriter) for writing .xlsx files or strings
  • Multiple worksheets in one workbook
  • Currency, date, numeric, and custom number-format cell formatting
  • Simple formula support and basic cell styling
  • Streaming writes that handle 100K+ row spreadsheets with low memory

Common Use Cases

  • Exporting large database result sets to Excel for download
  • Generating financial or sales reports with formatted currency and dates
  • Producing recurring data exports in memory-constrained environments
  • Replacing heavier spreadsheet libraries that run out of memory on big datasets

Under The Hood

Architecture - The library is a single xlsxwriter.class.php file defining the XLSXWriter class. Methods like writeSheet, writeSheetHeader, writeSheetRow, writeToFile, and writeToString build the XLSX package (a ZIP of XML parts) incrementally, buffering to a temp stream so full datasets never need to live in memory at once.

Tech Stack - Pure PHP with no runtime dependencies, using PHP’s built-in ZipArchive to assemble the OOXML package. Supports PHP 5.2.1+ and UTF-8 input.

Code Quality - The codebase is small and procedural in style with a testbench directory of example-driven checks; there is no formal unit-test framework, and the README is candid about the intentionally minimal feature set.

API Design - The API is deliberately terse and example-first: constructing a writer, passing arrays of rows, optionally supplying a header format map, and calling writeToFile is enough to produce a working spreadsheet, which keeps the learning curve very low.

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