Skip to content

[tip] How to migrate from PHPExcel to PHPSpreadsheet  #1445

Closed
@TomasVotruba

Description

I want to share a tip for people stuck on deprecated PHPExcel. It might take < 30 minutes to migrate to PHPSpreadsheet now.

I maintain @rectorphp open-source project, that handles instant migrations with AST (known in nikic/php-parser and PHPStan tools)

Recently I got into project that uses PHPExcel, read the migration README and made a migration set.

I wrote post about it: How to Migrate From PHPExcel to PHPSpreadsheet with Rector in 30 minutes


tl;dr;

composer require rector/rector --dev

# this command creates rector.php
vendor/bin/rector init

Add PHPOfficeSetList set to rector.php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\PHPOffice\Set\PHPOfficeSetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->sets([
        PHPOfficeSetList::PHPEXCEL_TO_PHPSPREADSHEET
    ]);
};

And you're ready to go 😉

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions