rabin 9ec735a000 edit | 11 months ago | |
---|---|---|
.. | ||
src | 11 months ago | |
.php-cs-fixer.dist.php | 11 months ago | |
.phpcs.xml.dist | 11 months ago | |
CHANGELOG.md | 11 months ago | |
CONTRIBUTING.md | 11 months ago | |
LICENSE | 11 months ago | |
README.md | 11 months ago | |
composer.json | 11 months ago | |
phpstan-baseline.neon | 11 months ago | |
phpstan-conditional.php | 11 months ago | |
phpstan.neon.dist | 11 months ago | |
phpunit10.xml.dist | 11 months ago |
PhpSpreadsheet is 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.
LTS: Support for PHP versions will only be maintained for a period of six months beyond the end of life of that PHP version.
Currently the required PHP minimum version is PHP 7.4, and we will support that version until 28th June 2023.
See the composer.json
for other requirements.
Use composer to install PhpSpreadsheet into your project:
composer require phpoffice/phpspreadsheet
If you are building your installation on a development machine that is on a different PHP version to the server where it will be deployed, or if your PHP CLI version is not the same as your run-time such as php-fpm
or Apache's mod_php
, then you might want to add the following to your composer.json
before installing:
{
"require": {
"phpoffice/phpspreadsheet": "^1.28"
},
"config": {
"platform": {
"php": "7.4"
}
}
}
and then run
composer install
to ensure that the correct dependencies are retrieved to match your deployment environment.
See CLI vs Application run-time for more details.
If you want to write to PDF, or to include Charts when you write to HTML or PDF, then you will need to install additional libraries:
For PDF Generation, you can install any of the following, and then configure PhpSpreadsheet to indicate which library you are going to use:
and configure PhpSpreadsheet using:
// Dompdf, Mpdf or Tcpdf (as appropriate)
$className = \PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf::class;
IOFactory::registerWriter('Pdf', $className);
or the appropriate PDF Writer wrapper for the library that you have chosen to install.
For Chart export, we support following packages, which you will also need to install yourself using composer require
and then configure PhpSpreadsheet using:
// to use jpgraph/jpgraph
Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph::class);
//or
// to use mitoteam/jpgraph
Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\MtJpGraphRenderer::class);
One or the other of these libraries is necessary if you want to generate HTML or PDF files that include charts; or to render a Chart to an Image format from within your code.
They are not necessary to define charts for writing to Xlsx
files.
Other file formats don't support writing Charts.
Read more about it, including install instructions, in the official documentation. Or check out the API documentation.
Please ask your support questions on StackOverflow, or have a quick chat on Gitter.
I am now running a Patreon to support the work that I do on PhpSpreadsheet.
Supporters will receive access to articles about working with PhpSpreadsheet, and how to use some of its more advanced features.
Posts already available to Patreon supporters:
And for Patrons at levels actively using PhpSpreadsheet:
The Next Article (currently Work in Progress):
My aim is to post at least one article each month, taking a detailed look at some feature of MS Excel and how to use that feature in PhpSpreadsheet, or on how to perform different activities in PhpSpreadsheet.
Planned posts for the future include topics like:
After a period of six months exclusive to Patreon supporters, articles will be incorporated into the public documentation for the library.
PhpSpreadsheet is the next version of PHPExcel. It breaks compatibility to dramatically improve the code base quality (namespaces, PSR compliance, use of latest PHP language features, etc.).
Because all efforts have shifted to PhpSpreadsheet, PHPExcel will no longer be maintained. All contributions for PHPExcel, patches and new features, should target PhpSpreadsheet master
branch.
Do you need to migrate? There is an automated tool for that.
PhpSpreadsheet is licensed under MIT.