PhpSpreadsheet
A pure PHP library for reading and writing spreadsheet files
PhpSpreadsheet is a pure-PHP library for reading and writing Excel and LibreOffice spreadsheet files, requiring no external programs or extensions beyond PHP itself.
PhpSpreadsheet is a code library for the PHP programming language that lets a program read and write spreadsheet files. It works with several formats, including Microsoft Excel files and LibreOffice Calc files. The README stresses that it is written in pure PHP, meaning it does not need any outside programs installed to do its job. A developer adds it to their own project so the software they are building can open a spreadsheet, pull data out of it, or create a new spreadsheet file from scratch.
The README notes that this is the master branch, kept up to date with security and bug fixes. It spells out which versions of PHP are supported: the minimum required is PHP 8.1, and the project commits to supporting versions for six months past their official end of life. For actually installing and using the library, the README mostly points elsewhere, to the official documentation and API reference hosted online, and it suggests StackOverflow or a Gitter chat room for support questions.
A large part of the README describes a Patreon page run by the maintainer, Mark Baker, to fund his work. Supporters get early access to in-depth articles about features of Excel and how to use them in PhpSpreadsheet. The README lists articles already published, such as how Excel handles dates and times and how to loop through rows and cells, along with planned future topics like tables, charts, images, conditional formatting, and data validation. The author aims to publish at least one article a month, and after six months each article is folded into the free public documentation.
The README also explains the relationship to an older project called PHPExcel. PhpSpreadsheet is the next version of PHPExcel and deliberately breaks compatibility in order to clean up and modernize the code. PHPExcel is no longer maintained, so all new work should go to PhpSpreadsheet, and there is an automated tool to help people move their existing code over. The library is released under the MIT license, which is a permissive open source license.
Where it fits
- Read data from an uploaded Excel file in your PHP web app and save the rows to a database.
- Generate and download a formatted Excel report from your PHP backend without needing Excel installed on the server.
- Migrate existing PHPExcel code to PhpSpreadsheet using the automated migration tool.
- Create LibreOffice Calc spreadsheets programmatically from PHP for data export.