PhpSpreadsheet is the next version of PHPExcel. It breaks compatibility to dramatically improve the code base quality through namespaces, PSR compliance, and use of latest PHP language features.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/PHPOffice/PhpSpreadsheet/llms.txt
Use this file to discover all available pages before exploring further.
Automated Migration Tool
RectorPHP can automatically migrate your codebase. Note that this support has been dropped from current releases of Rector, so you need to require an earlier release.Installation
Assuming your files to be migrated live insrc/, install the required packages:
Configuration
Initialize Rector configuration:PHPOfficeSetList to your rector.php config:
Run Migration
Execute Rector on your codebase:Manual Changes
RectorPHP should handle most changes, but you may need to apply some manual updates:Renamed Readers and Writers
When usingIOFactory::createReader(), IOFactory::createWriter(), and IOFactory::identify(), the reader/writer short names have changed:
| Before | After |
|---|---|
'CSV' | 'Csv' |
'Excel2003XML' | 'Xml' |
'Excel2007' | 'Xlsx' |
'Excel5' | 'Xls' |
'Gnumeric' | 'Gnumeric' |
'HTML' | 'Html' |
'OOCalc' | 'Ods' |
'OpenDocument' | 'Ods' |
'PDF' | 'Pdf' |
'SYLK' | 'Slk' |
Simplified IOFactory
The following methods have been replaced:PHPExcel_IOFactory::getSearchLocations()PHPExcel_IOFactory::setSearchLocations()PHPExcel_IOFactory::addSearchLocation()
IOFactory::registerReader() and IOFactory::registerWriter() instead. IOFactory now relies on class autoloading.
Removed Deprecated Methods
Worksheet::duplicateStyleArray()
DataType::dataTypeForValue()
Conditional::getCondition()
Conditional::setCondition()
Worksheet::getDefaultStyle()
Worksheet::setDefaultStyle()
Worksheet::setSharedStyle()
Worksheet::getSelectedCell()
Writer\Xls::setTempDir()
Autoloader
The classPHPExcel_Autoloader has been removed entirely and is replaced by Composer’s autoloading mechanism.
Writing PDF
PDF libraries must be installed via Composer. The following methods have been removed:PHPExcel_Settings::getPdfRenderer()PHPExcel_Settings::setPdfRenderer()PHPExcel_Settings::getPdfRendererName()PHPExcel_Settings::setPdfRendererName()
IOFactory::registerWriter() instead:
Rendering Charts
Chart rendering for HTML or PDF outputs has been simplified. While JpGraph support is still available, the version distributed via Composer is no longer maintained.The package mitoteam/jpgraph is distributed via Composer and is fully compatible with JpGraph. We recommend using it for chart rendering.
PclZip and ZipArchive
Support for PclZip has been dropped in favor of the more complete PHP extension ZipArchive. The following have been removed:PclZipPHPExcel_Settings::setZipClass()PHPExcel_Settings::getZipClass()PHPExcel_Shared_ZipArchivePHPExcel_Shared_ZipStreamWrapper
Cell Caching
Cell caching was heavily refactored to leverage PSR-16. Most classes related to this feature were removed:PHPExcel_CachedObjectStorage_APCPHPExcel_CachedObjectStorage_DiscISAMPHPExcel_CachedObjectStorage_ICachePHPExcel_CachedObjectStorage_IgbinaryPHPExcel_CachedObjectStorage_MemcachePHPExcel_CachedObjectStorage_MemoryPHPExcel_CachedObjectStorage_MemoryGZipPHPExcel_CachedObjectStorage_MemorySerializedPHPExcel_CachedObjectStorage_PHPTempPHPExcel_CachedObjectStorage_SQLitePHPExcel_CachedObjectStorage_SQLite3PHPExcel_CachedObjectStorage_Wincache
\PhpOffice\PhpSpreadsheet::getCellCollection()was renamed to\PhpOffice\PhpSpreadsheet::getCoordinates()\PhpOffice\PhpSpreadsheet::getCellCacheController()was renamed to\PhpOffice\PhpSpreadsheet::getCellCollection()
Dropped Conditionally Returned Cell
The following methods will always return the Worksheet, never the Cell or Rule:Worksheet::setCellValue()Worksheet::setCellValueByColumnAndRow()(deprecated)Worksheet::setCellValueExplicit()Worksheet::setCellValueExplicitByColumnAndRow()(deprecated)Worksheet::addRule()
Standardized Keys for Styling
Array keys used for styling have been standardized to use the same wording and casing as getter and setter methods:Dedicated Class for Coordinate Manipulation
Methods to manipulate coordinates that previously existed inPHPExcel_Cell have been extracted to \PhpOffice\PhpSpreadsheet\Cell\Coordinate:
absoluteCoordinate()absoluteReference()buildRange()columnIndexFromString()coordinateFromString()extractAllCellReferencesInRange()getRangeBoundaries()mergeRangesInCollection()rangeBoundaries()rangeDimension()splitRange()stringFromColumnIndex()
Column Index Based on 1
PHPExcel_Worksheet::cellExistsByColumnAndRow()PHPExcel_Worksheet::freezePaneByColumnAndRow()PHPExcel_Worksheet::getCellByColumnAndRow()PHPExcel_Worksheet::getColumnDimensionByColumn()PHPExcel_Worksheet::getCommentByColumnAndRow()PHPExcel_Worksheet::getStyleByColumnAndRow()PHPExcel_Worksheet::insertNewColumnBeforeByIndex()PHPExcel_Worksheet::mergeCellsByColumnAndRow()PHPExcel_Worksheet::protectCellsByColumnAndRow()PHPExcel_Worksheet::removeColumnByIndex()PHPExcel_Worksheet::setAutoFilterByColumnAndRow()PHPExcel_Worksheet::setBreakByColumnAndRow()PHPExcel_Worksheet::setCellValueByColumnAndRow()PHPExcel_Worksheet::setCellValueExplicitByColumnAndRow()PHPExcel_Worksheet::setSelectedCellByColumnAndRow()PHPExcel_Worksheet::stringFromColumnIndex()PHPExcel_Worksheet::unmergeCellsByColumnAndRow()PHPExcel_Worksheet::unprotectCellsByColumnAndRow()PHPExcel_Worksheet_PageSetup::addPrintAreaByColumnAndRow()PHPExcel_Worksheet_PageSetup::setPrintAreaByColumnAndRow()

