Phpspreadsheet: [tip] How to migrate from PHPExcel to PHPSpreadsheet

Created on 16 Apr 2020  路  6Comments  路  Source: PHPOffice/PhpSpreadsheet

Hi!

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
vendor/bin/rector process src --set phpexcel-to-phpspreadsheet

And you're ready to go :wink:

All 6 comments

This is great thank you for sharing. I would like to integrate this info official documentation. Do you have any opinion on how to do that? Replace everything with Rector? Or replace only our regexp tool and keep description of other changes?

Replace everything with Rector?

:+1: That would the best. I tried to cover all the changes described in the migration guide.

If you find any mistake or would like to add more changes to automate, let me know. It should be doable :wink:

@TomasVotruba could you please edit your blog post and replace all references from:

https://github.com/PHPOffice/PhpSpreadsheet/blob/master/docs/topics/migration-from-PHPExcel.md

to:

https://github.com/PHPOffice/PhpSpreadsheet/blob/50d78ce7898ee3a540cefd9693085b3636e578e6/docs/topics/migration-from-PHPExcel.md

So the old manual way is still somewhat accessible.

Sure, that's a good idea. There you go: https://github.com/rectorphp/getrector.org/commit/0596ce4bf406c09fc24f787f588d03cfd138c67f

If you share a tweet about this, just mention @rectorphp and I'll retweet it.

Is it possible to use this with Codeigniter 3? It seems like there's no way to make it work given how CodeIgniter controller and model classes are loaded. Sadly there's no information on how to migrate manually either, so I'm stuck with PHPExcel.

You can have a look at the old doc here: https://github.com/PHPOffice/PhpSpreadsheet/blob/1.12.0/docs/topics/migration-from-PHPExcel.md

And if you need the old semi-automated migration tool, you can temporarily install v1.12.0, do the migration, and then update to latest version.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PowerKiKi picture PowerKiKi  路  5Comments

Typel picture Typel  路  5Comments

AlexPravdin picture AlexPravdin  路  4Comments

jcroucher picture jcroucher  路  4Comments

smartlara picture smartlara  路  5Comments