OpenSpout

A fast, low-memory PHP library for reading and writing CSV, XLSX, and ODS spreadsheet files.

Library
Composer
vv5.10.3
1,217stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
91/100Excellent
Development Activity92
Maintenance100
Community76
Maturity56
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture80
Code Quality82
Innovation68
Learning Curve72

OpenSpout is a community-maintained fork of box/spout that reads and writes spreadsheet files (CSV, XLSX, ODS) in PHP while keeping memory usage under roughly 3MB even for very large files, by streaming rows instead of building the whole document in memory. It’s used anywhere a PHP application needs to generate or parse spreadsheet exports/imports at scale — reporting tools, data exports, ETL pipelines — without hitting the memory limits typical of DOM-based spreadsheet libraries.

What You Get

  • Streaming Writer implementations for CSV, XLSX, and ODS that keep memory usage flat regardless of file size
  • Streaming Reader implementations for the same three formats, iterating rows without loading the whole file
  • Shared Common\Entity classes (Row, Cell, Style) for consistent styling and cell typing across formats
  • Format-specific writer/reader subpackages (Reader/XLSX, Writer/ODS, etc.) isolating each file format’s parsing/generation logic
  • An active fork lineage from box/spout with a documented v3→v4 upgrade guide and continued API evolution

Common Use Cases

  • Generating large data exports (reports, invoices, bulk records) as XLSX or CSV without exhausting server memory
  • Importing bulk spreadsheet uploads (product catalogs, user lists) into a database via streaming row iteration
  • Building ETL pipelines that convert between CSV/XLSX/ODS formats at scale
  • Replacing box/spout in existing codebases after that project became unmaintained, per OpenSpout’s documented migration path

Under The Hood

Architecture: The codebase splits cleanly along two axes — Reader vs Writer, and format (CSV/XLSX/ODS) — with shared concerns (row/cell entities, styling, exceptions) centralized under Common; XLSX/ODS writers generate the underlying XML/ZIP structure incrementally rather than building a full DOM, which is the mechanism behind its low memory footprint. Tech Stack: Modern PHP (actively tested against current PHP versions per its 2026 commit activity), zero heavyweight dependencies beyond PHP’s native ZipArchive/XMLWriter extensions, with PHPStan static analysis, PHPUnit tests, PHPBench for performance benchmarking, and Infection for mutation testing all wired into CI. Code Quality: The repo carries a published Infection mutation-score badge (a stronger quality signal than plain coverage), maintains a benchmarks/ directory to catch performance regressions, and documents breaking changes rigorously in UPGRADE.md — indicating deliberate attention to both correctness and the memory/speed guarantees that are the library’s core value proposition. API Design: Reader/Writer usage follows a consistent, minimal pattern across formats (Reader::open() → iterate getSheetIterator()/rows; Writer::openToFile()addRow()close()), so switching between CSV, XLSX, and ODS requires almost no code change beyond the class name.

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