Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
TomasVotruba opened this issue Apr 16, 2020 · 6 comments
Closed

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

TomasVotruba opened this issue Apr 16, 2020 · 6 comments

Comments

@TomasVotruba
Copy link
Contributor

TomasVotruba commented Apr 16, 2020

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 😉

@TomasVotruba TomasVotruba changed the title Help with migration from PHPExcel [tip] How to migrate from PHPExcel to PHPSpreadsheet Apr 16, 2020
@PowerKiKi PowerKiKi pinned this issue Apr 26, 2020
@PowerKiKi
Copy link
Member

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?

@TomasVotruba
Copy link
Contributor Author

Replace everything with Rector?

👍 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 😉

@PowerKiKi
Copy link
Member

@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.

@PowerKiKi PowerKiKi unpinned this issue May 2, 2020
@TomasVotruba
Copy link
Contributor Author

Sure, that's a good idea. There you go: rectorphp/getrector-com@0596ce4

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

PowerKiKi added a commit that referenced this issue May 31, 2020
### Added

- Support writing to streams in all writers [#1292](#1292)
- Support CSV files with data wrapping a lot of lines [#1468](#1468)
- Support protection of worksheet by a specific hash algorithm [#1485](#1485)

### Fixed

- Fix Chart samples by updating chart parameter from 0 to DataSeries::EMPTY_AS_GAP [#1448](#1448)
- Fix return type in docblock for the Cells::get() [#1398](#1398)
- Fix RATE, PRICE, XIRR, and XNPV Functions [#1456](#1456)
- Save Excel 2010+ functions properly in XLSX [#1461](#1461)
- Several improvements in HTML writer [#1464](#1464)
- Fix incorrect behaviour when saving XLSX file with drawings [#1462](#1462),
- Fix Crash while trying setting a cell the value "123456\n" [#1476](#1481)
- Improved DATEDIF() function and reduced errors for Y and YM units [#1466](#1466)
- Stricter typing for mergeCells [#1494](#1494)

### Changed

- Drop support for PHP 7.1, according to https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support
- Drop partial migration tool in favor of complete migration via RectorPHP [#1445](#1445)
- Limit composer package to `src/` [#1424](#1424)
@jeanmobayed
Copy link

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.

@PowerKiKi
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants