PhpSpreadsheet: reading and writing Excel files in pure PHP
A pure PHP library for reading and writing spreadsheet files
At a glance
- What is it?
- PhpSpreadsheet is the maintained successor to PHPExcel, a pure PHP library for reading and writing xlsx, xls, ODS and other spreadsheet formats. It is aimed at PHP applications that need to generate or parse workbooks without a Java bridge or a headless office install.
- Who is it for?
- Adopt PhpSpreadsheet if you are on PHP 8.2 or newer and need to generate or parse workbook files inside a normal PHP request or worker, without a Java bridge or headless LibreOffice. Do not adopt it if you are pinned to PHP 8.1 or older, or if you need a spreadsheet engine with pivot tables, macros or full formula evaluation, since the library copies and recalculates formulas rather than implementing Excel.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 1 day ago.
- What is it written in?
- Mainly PHP, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 29, 2026, and from our analysis. They are not legal advice.
Editorial analysis
The problem PhpSpreadsheet solves for PHP applications
A PHP application that has to hand a user a spreadsheet usually faces one of three bad options: shell out to a headless LibreOffice or a Java-based library, ask the user to paste CSV into Excel, or write the xlsx zip structure by hand. PhpSpreadsheet takes the first option off the table. The README describes it as "a library written in pure PHP and offers a set of classes that allow you to read and write various spreadsheet file formats such as Excel and LibreOffice Calc." Pure PHP matters here because it means no external process, no JVM, and no native extension beyond what a normal PHP build ships with.
The audience is narrow but deep: backend developers who need to export a report, import a customer-supplied workbook, or produce a file that opens correctly in Excel rather than triggering a format warning. The README notes the package is the next version of PHPExcel and that PHPExcel "will no longer be maintained," with all contributions targeting the PhpSpreadsheet master branch. If you are still on the old PHPExcel API, the repository ships a migration guide under docs/topics/migration-from-PHPExcel.md and an automated tool for that migration.
How the reader, writer and worksheet model fit together
The library is organised around a small set of objects. You create a Spreadsheet, get a Worksheet from it, and read or write cells through a coordinate-based API. A reader class for the target format parses the file into that object graph; a writer class serialises the object graph back out. The README does not lay out the class hierarchy, but the repository structure makes the split visible: src/ holds the library, samples/ holds runnable examples grouped by topic, and tests/ holds the test suite.
The samples directory is the most useful map of what the library actually covers. It contains folders such as samples/Basic/, samples/Chart/, samples/ConditionalFormatting/, samples/DateTime/, samples/DefinedNames/, samples/Autofilter/, samples/Database/, and samples/Financial1/ through samples/Financial3/. That spread tells you the object model is not just cells and values: charts, conditional formats, defined names and autofilters all have representation in the API. The topics list on the repository confirms the format surface: excel, gnumeric, libreoffice, msexcel, ods, sylk, xls, xlsx.
The trade-off in this design is memory. A pure PHP object graph for a large workbook is expensive, because every cell becomes an object rather than a row in a stream. The README does not discuss memory behaviour, so treat that as something to measure against your own files rather than something the project promises. The docs site is where the project points for detail; the README itself defers with "Read more about it, including install instructions, in the official documentation."
Installing PhpSpreadsheet with Composer and writing a first file
The README does not inline install steps. It points at the documentation with "See the install instructions" and links to phpspreadsheet.readthedocs.io. The package is published on Packagist under the name phpoffice/phpspreadsheet, which is the name Composer resolves against. The README states the required PHP minimum is PHP 8.2, so a machine on an older runtime will fail resolution rather than install quietly.
Once installed, the repository's samples/ directory is the place to look for working code. It groups examples by topic, with folders such as samples/Basic/, samples/Chart/, samples/ConditionalFormatting/, samples/DateTime/, samples/DefinedNames/, samples/Autofilter/ and samples/Database/, and it includes samples/Bootstrap.php to wire the sample scripts up. That file's presence is a hint that the samples assume an autoloader is available rather than each script bootstrapping itself.
What the README does not give is a code sample of its own. It defers entirely to the documentation site and to the API documentation at phpoffice.github.io/PhpSpreadsheet for the class-level detail. So the honest first step is: install the package, then open the samples directory and read a script that matches what you need to do, because the README will not walk you through it.
Where PhpSpreadsheet is the wrong choice
The PHP version floor is the first hard boundary. The README states the required minimum is PHP 8.2 and that support runs until 30th June 2027. It also spells out the policy: for maintained branches, PHP version support lasts only six months beyond that PHP version's end of life, and dropping support after that date "will not be considered a breaking change." If your production host is on PHP 8.1 or earlier, this library is not an option without an upgrade, and the upgrade is yours to schedule, not the project's.
The second boundary is formula handling. PhpSpreadsheet is not a calculation engine in the way Excel is. If your workflow depends on evaluating arbitrary user-authored formulas, or on features Excel treats as first-class such as pivot tables and macros, the library's scope is reading and writing files, not reproducing the application. The README's own framing is about classes that read and write formats. A Patreon post listed as work in progress, "Formula for Success," is described as advice on debugging formulae that do not produce the expected result, which suggests formula behaviour is a place users get surprised.
Third, the master branch is described as "maintained for security and bug fixes." That is a maintenance statement, not a feature roadmap. If you need a capability that is not in the current API, the README does not promise it will arrive.
PhpSpreadsheet versus PhpSpreadsheet's own predecessor and a CSV shortcut
The most direct alternative is PHPExcel, the library PhpSpreadsheet replaces. The README is explicit about the difference: PhpSpreadsheet "breaks compatibility to dramatically improve the code base quality (namespaces, PSR compliance, use of latest PHP language features, etc.)." That is the whole trade. You give up drop-in compatibility with existing PHPExcel code and gain namespaces and modern PHP. The project ships a migration tool for exactly this reason, and the README says patches and new features should target PhpSpreadsheet master, not PHPExcel. Choosing PHPExcel today means choosing an unmaintained codebase.
The other alternative is not a library at all: write CSV and let the user open it in Excel. That works when the output is a flat table of plain values and the consumer tolerates a manual import step. It stops working the moment you need multiple sheets, number formats, formulas, styling, merged cells, or a file that opens without an import wizard. The related searches include "phpspreadsheet merge cells," and merged cells are precisely the kind of thing CSV cannot express. If your export is genuinely a rectangle of text, CSV is cheaper and has no PHP version floor. If it is a workbook, it is not.
Maintenance, licence and upgrade cost
The repository is not archived, and the last push was on 2026-09-19. Recent releases include 5.10.0, 3.10.8 and 2.4.8, all dated 2026-09-17. The presence of three parallel release lines is worth noticing: it means the project maintains more than one major version at a time, so a pin to an older major is not automatically abandoned. The README does not document the support window for each line, so check the release notes for the line you intend to use.
The licence is MIT, which is permissive and imposes no copyleft obligation on your application. The README links the LICENSE file at the repository root. Nothing here is legal advice; if your organisation has licence review, the file to read is LICENSE.
Upgrade cost has two components. The PHP floor moves: the README's policy of dropping support six months after a PHP version's end of life, without treating it as a breaking change, means a PHP upgrade can force a library upgrade on the project's timetable. The API itself is the second component, and the PHPExcel migration guide is the precedent for how disruptive a major transition can be. The README does not document rollback, so plan upgrades with a pinned version in composer.json and a lock file you can revert.
Editorial conclusion
Adopt PhpSpreadsheet if you are on PHP 8.2 or newer and need to generate or parse workbook files inside a normal PHP request or worker, without a Java bridge or headless LibreOffice. Do not adopt it if you are pinned to PHP 8.1 or older, or if you need a spreadsheet engine with pivot tables, macros or full formula evaluation, since the library copies and recalculates formulas rather than implementing Excel. Before committing, confirm the PHP minimum against your deployment target in composer.json, and check the docs for the specific format you must read or write, because writer support is not uniform across xlsx, xls, ODS and CSV.
Frequently asked questions
How do I install PhpSpreadsheet using Composer?
The package is published on Packagist as phpoffice/phpspreadsheet, which is the name Composer resolves. The README does not inline the command; it links to the official documentation for install instructions and states the required PHP minimum is PHP 8.2.
How can I read Excel files using PHP?
PhpSpreadsheet provides reader classes that parse spreadsheet formats into its object model, and the README describes it as a pure PHP library for reading and writing formats such as Excel and LibreOffice Calc. The repository's samples/ directory contains runnable examples, including samples/Basic/.
How can I export data from PHP to Excel?
The library offers a set of classes for writing spreadsheet formats, and the README lists xlsx among the formats it handles. The samples/ directory groups working examples by topic, so that is where to find the write path for your target format.
Is there a PHP Excel package available?
Yes. PhpSpreadsheet is the maintained successor to PHPExcel, and the README states that PHPExcel will no longer be maintained and that all contributions should target the PhpSpreadsheet master branch. It is licensed under MIT.
how to use phpspreadsheet without composer
The README does not document a manual installation path. It points at the official documentation for install instructions, and the package is published on Packagist, which is the distribution channel Composer uses.
how to install phpspreadsheet in xampp
The README gives no XAMPP-specific instructions. The stated requirement is PHP 8.2 as the minimum version, so a XAMPP build running that version or newer is the relevant constraint to check before following the documented install steps.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/phpoffice-phpspreadsheet)