explaingit

phpoffice/phpspreadsheet

13,925PHPAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

PhpSpreadsheet is a pure-PHP library for reading and writing Excel and LibreOffice spreadsheet files, requiring no external programs or extensions beyond PHP itself.

Mindmap

mindmap
  root((PhpSpreadsheet))
    What it does
      Read spreadsheets
      Write spreadsheets
      Pure PHP no deps
    Supported Formats
      Excel xlsx and xls
      LibreOffice ods
    Use Cases
      Import uploaded files
      Generate reports
      Migrate from PHPExcel
    Setup
      PHP 8.1 minimum
      Install via Composer
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Read data from an uploaded Excel file in your PHP web app and save the rows to a database.

USE CASE 2

Generate and download a formatted Excel report from your PHP backend without needing Excel installed on the server.

USE CASE 3

Migrate existing PHPExcel code to PhpSpreadsheet using the automated migration tool.

USE CASE 4

Create LibreOffice Calc spreadsheets programmatically from PHP for data export.

Tech stack

PHPComposer

Getting it running

Difficulty · easy Time to first run · 30min

Requires PHP 8.1 or later and Composer, no external programs, Office install, or special PHP extensions needed.

Use freely for any purpose including commercial projects, as long as you keep the copyright notice.

In plain English

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.

Copy-paste prompts

Prompt 1
Using PhpSpreadsheet, write PHP code to read every row from an uploaded .xlsx file and return them as a PHP array.
Prompt 2
Help me generate a formatted Excel report with a header row, styled cells, and data rows using PhpSpreadsheet.
Prompt 3
Show me how to run the PhpSpreadsheet migration tool to automatically update my existing PHPExcel code to the new library.
Prompt 4
Write PHP code with PhpSpreadsheet to loop through all rows in a spreadsheet and insert each row into a MySQL database, skipping the header row.
Open on GitHub → Explain another repo

← phpoffice on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.