PhpSpreadsheet

Read, write, and manipulate Excel, CSV, and ODS spreadsheet files in pure PHP with no external office suite required.

Library
Composer
v5.8.1
13,975stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
55/100Fair
Development Activity48
Maintenance0
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
86/100Excellent
Architecture88
Code Quality90
Innovation82
Learning Curve85

PhpSpreadsheet is a pure PHP library for reading, writing, and manipulating spreadsheet files across formats including XLSX, XLS, ODS, CSV, Gnumeric, and SYLK. It exposes an in-memory object model — worksheets, cells, styles, charts, and formulas — that mirrors how desktop spreadsheet applications represent data, so applications can build reports, generate exports, or parse uploaded spreadsheets without shelling out to Excel or LibreOffice.

Originally created as the successor to the discontinued PHPExcel project, PhpSpreadsheet rebuilt the library around namespaces, PSR compliance, and modern PHP practices while keeping the same broad format coverage. It ships a calculation engine that evaluates hundreds of Excel formula functions, a flexible IOFactory for auto-detecting file types, and writer support for PDF export via Dompdf, Mpdf, or TCPDF.

What You Get

  • A Spreadsheet object model with worksheets, cells, styles, rich text, charts, comments, and defined names
  • Readers and writers for XLSX, XLS, ODS, CSV, Gnumeric, SYLK, HTML, and XML formats via a single IOFactory
  • A formula calculation engine supporting hundreds of Excel functions across math, date/time, financial, statistical, and text categories
  • PDF export writers that integrate with Dompdf, Mpdf, or TCPDF
  • Fluent, chainable APIs for styling, formatting, and manipulating cells and worksheets

Common Use Cases

  • Generating downloadable Excel reports from application data (invoices, financial summaries, exports)
  • Importing user-uploaded spreadsheets to bulk-load records into a database
  • Building admin dashboards that let users export filtered data tables as XLSX or CSV
  • Converting spreadsheets to PDF for printable reports

Under The Hood

Architecture — PhpSpreadsheet centers on an in-memory Spreadsheet object model (src/PhpSpreadsheet/Spreadsheet.php) composed of Worksheet, Cell, Style, Chart, and RichText sub-models that are fully decoupled from any file format. Persistence is handled by pluggable Reader\IReader and Writer\IWriter implementations, one namespace per format (Reader\Xlsx, Reader\Xls, Reader\Ods, Reader\Gnumeric, etc.), each with format-specific parsing logic — the Xlsx reader unzips and parses OOXML, while Xls implements the legacy binary BIFF format directly. IOFactory (src/PhpSpreadsheet/IOFactory.php) auto-detects a file’s format by extension and a canRead() probe, and exposes registerReader/registerWriter so consumers can add custom formats without modifying the library. A separate Calculation subsystem (src/PhpSpreadsheet/Calculation/Calculation.php plus per-category function folders like DateTimeExcel, Financial, Engineering) implements its own formula tokenizer/parser/evaluator, letting formulas be recalculated purely in PHP. The result is a clean read → model → calculate → write pipeline where every stage is independently swappable.

Tech Stack — Pure PHP 8.2+, with composer.json requiring a long list of core extensions (ext-zip, ext-xml, ext-gd, ext-dom, ext-mbstring, etc.) needed to parse ZIP-based OOXML/ODS containers, render embedded images, and handle multi-byte text. Runtime dependencies are deliberately minimal: markbaker/complex and markbaker/matrix back the complex-number and matrix math used by financial/engineering formula functions, maennchen/zipstream-php streams ZIP writes for xlsx/ods output without buffering the whole file in memory, and psr/simple-cache provides an optional caching interface. PDF export is delegated to whichever of Dompdf, Mpdf, or TCPDF the consuming application already has installed, rather than bundling one. Development tooling includes PHPUnit 10/11, PHPStan at level 10 (the strictest setting, with a small tracked baseline), and both PHP-CS-Fixer and PHP_CodeSniffer (including a PHPCompatibility ruleset) to enforce style and PHP-version compatibility.

Code Quality — The repository ships 1,214 dedicated PHPUnit test files (tests/PhpSpreadsheetTests/) covering readers, writers, styles, and individual formula functions, plus a tests/Benchmark suite for performance-sensitive paths like streaming XLSX reads. Static analysis runs at PHPStan level 10 — the tool’s maximum strictness — with violations tracked in a small, actively-shrinking phpstan-baseline.neon rather than suppressed wholesale. Core classes like Cell use typed properties, explicit nullable/mixed typing, and dedicated Exception classes per subsystem (Calculation\Exception, Reader\Exception, Writer\Exception) rather than generic exceptions, making failure modes easy to catch narrowly. A .php-cs-fixer.dist.php config with over a dozen configured rule sets and a CI-enforced composer check script (phpcs, PHPCompatibility, php-cs-fixer, phpstan, phpunit) keep style and typing consistent across 415 contributors.

API Design — The public API favors fluent, chainable method calls (e.g. $spreadsheet->getProperties()->setCreator(...)->setTitle(...)), documented explicitly in the official architecture guide, while still allowing a plain imperative style for consumers who prefer it. IOFactory::load() gives a one-line entry point that auto-detects file type, while explicit IOFactory::createReader()/createWriter() calls remain available when the format is already known or non-standard. Constants like IOFactory::READER_XLSX and WRITER_ODS centralize format identifiers instead of scattering magic strings. The tradeoff is surface area: full mastery of styling, conditional formatting, and the 300+ formula functions requires digging through extensive docs, but the entry-level workflow — IOFactory::load($file), read cells, IOFactory::createWriter($spreadsheet, 'Xlsx')->save($out) — is only a few lines.

Used by 7 apps in this directory

PHP
78%
Other

Craft CMS

CMS

3,601

A developer-first PHP CMS with clean-slate content modeling, auto-generated GraphQL API, and a four-tier edition system that scales from solo projects to enterprise deployments.

View details
96
Repo Health
83
Technical
63
Dependency
Built with
PHP78%
JavaScript14%
Updated today
PHP
66%
AGPL 3.0

EspoCRM

Marketing · Ecommerce · CRM

3,259

Open-source CRM platform with metadata-driven customization, field-level permissions, and a full REST API — deploy on your own infrastructure.

View details
97
Repo Health
72
Technical
64
Dependency
Built with
PHP66%
JavaScript24%
Updated yesterday
JavaScript
70%
AGPL 3.0

Fleetbase

Logistics

2,510

Modular open-source logistics and supply chain operating system

View details
91
Repo Health
75
Technical
68
Dependency
Built with
JavaScript70%
PHP10%
Updated today
PHP
85%
Other

Invoice Ninja

Invoicing Finance · Project Management

10,008

Self-hostable invoicing, time-tracking, and multi-gateway payment platform for freelancers and small businesses, with built-in e-invoicing compliance for EU and global standards.

View details
97
Repo Health
83
Technical
62
Dependency
Built with
PHP85%
XSLT10%
Updated 2 days ago
PHP
86%
AGPL 3.0

Kimai

Invoicing Finance · Project Management

4,918

Professional open-source time tracking with invoicing, multi-user support, SAML/LDAP auth, and a full REST API—self-host it or use the cloud.

View details
94
Repo Health
78
Technical
63
Dependency
Built with
PHP86%
Updated today
JavaScript
44%
Other

LimeSurvey

Forms Surveys

3,698

The world's most flexible open-source survey platform with 900+ templates, conditional logic, 80+ languages, and full GDPR compliance for any scale.

View details
86
Repo Health
62
Technical
62
Dependency
Built with
JavaScript44%
PHP34%
CSS12%
Updated today
PHP
82%
Other

Mautic

Automation · Marketing · Ecommerce

10,366

The world's largest open source marketing automation platform — own your data, run multi-channel campaigns, and escape vendor lock-in forever.

View details
98
Repo Health
76
Technical
64
Dependency
Built with
PHP82%
Updated yesterday

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