-
-
Notifications
You must be signed in to change notification settings - Fork 2k
[4.x] Upgrade PHPOffice to v5 #4302
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
[4.x] Upgrade PHPOffice to v5 #4302
Conversation
|
Thanks for the PR, this seems to be the first actual right attempt of updating phpoffice that actually implemented all the breaking changes. As this is going to be in the next major release in which I'm planning to drop support for all unsupported PHP and Laravel versions, you can't drop them from the PR as well. I don't see a need in supporting v2 and v3, we can just bump it straight away to v4 What's the problem with the loadSheetsOnly? Did you find a breaking change note about this? What things are still WIP? |
|
Thanks for the review, @patrickbrouwers. There is nothing else left besides loading the sheet by incorrect name, removing broken test and bumping dependency requirements. I’ll apply your suggestions and target v4 soon. |
…grade # Conflicts: # tests/Cache/BatchCacheTest.php
e153bda to
f605839
Compare
|
Kindly help to create |
|
I'll look into it after my holiday. |
|
Hi @patrickbrouwers I hope you had a great holiday and was wondering if you had time to look into this again. Please let me know if you wish to adjust anything with above implementation. |
|
Hey @IonBazan, I currently don't have to time to look into this. As this is a big change that I really want to test carefully before tagging, I need to have the time to spend more on it than the few minutes I have right now :( I can't promise when atm. |
|
V5 was just released... |
|
I am a maintainer for PhpSpreadsheet. Please let me know if there is any way I can assist in this effort. In particular, we cannot revert to the old behavior when Mention was made above that |
|
That sounds good, thx! |
In PhpSpreadsheet Release 1, if the LoadSheetsOnly option was specified, and no sheets matched, a new blank sheet was created. This behavior changed in PhpSpreadsheet Release 2, so that an exception wound up being thrown instead. Although the Release 2 approach seems more sensible to me, it was actually collateral damage from a different change, and was not an intentional result. The difference in behavior is causing a problem for Laravel-Excel. In particular, a PR which would move their supported PhpSpreadsheet release from 1 to 5, is delayed because this change in behavior breaks part of their test suite. See SpartnerNL/Laravel-Excel#4302. We would very much like them to get off release 1. I volunteered to add a compatibility option to the Readers which would emulate the release 1 behavior. The result is this PR. Usage: ```php $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); $reader->setLoadSheetsOnly([list of sheet names]); if (method_exists($reader, 'setCreateBlankSheetIfNoneRead')) { $reader->setCreateBlankSheetIfNoneRead(true); } ``` In addition to Xlsx Reader, the method is available for Xls, Ods, Xml, and Gnumeric.
|
I have created PR 4618 for PhpSpreadsheet (there is already a link to it above). Typical usage is documented in the commit message. I plan to merge it to master early next week, which will, I hope, give you a chance to see if it meets your needs before I do that. I am not planning a new release for PhpSpreadsheet until just before or just after Php8.5 is released, but, if you need it sooner, let me know. Also, please let me know if there's anything else you'd like to see which would help move this PR forward. |
|
Thanks @oleibman ! |
|
Thank you @oleibman - I have tried to use the branch you provided and restored the changes in |
I had to add this as a compatibility option in order to avoid introducing a new breaking change in PhpSpreadsheet. You need to add the following to your test: if (method_exists($reader, 'setCreateBlankSheetIfNoneRead')) {
$reader->setCreateBlankSheetIfNoneRead(true);
}Once you do that, your test should succeed for both PhpSpreadsheet 1 and PhpSpreadsheet 5. |
22849df to
512c375
Compare
|
Thanks, I must have missed that! It seems to be working fine now 👍🏻 |
|
@IonBazan Thank you for the confirmation. My PR is now moved to dev-master, and will be part of a formal release some time this week. |
|
PhpSpreadsheet 5.1.0, including the compatibility option described above, is now released. (Also 3.10.1 and 2.4.1 just in case.) |
512c375 to
2257b98
Compare
2257b98 to
310b937
Compare
|
@patrickbrouwers I've bumped minimal version requirement to v5.1 and added testing under PHP 8.5.
|
|
@IonBazan I'm following just following this conversation, expectantly waiting for a merge. Thanks for your work so far! I was looking into the constant you mentioned, but it's a difficult one to solve because the new constant It's up to @patrickbrouwers if this is a show stopper for this PR. In my opinion it is not as this deprecation is only in the test suite and PHP 8.5 is still some months away. |
|
Don't worry about the deprecation message. This is a message that will only appear the 8.5 testsuite. On future laravel/testbench updates this deprecation will be fixed. |
|
As this looks good now, I've merged it in the 4.x branch. I'll need a bit more time to prepare the actual 4.0 release |
|
@patrickbrouwers Any news on that 4.X release? |
|
I'm unfortunalty short on time atm, but you can of course always use the |
Please take note of our contributing guidelines: https://docs.laravel-excel.com/3.1/getting-started/contributing.html
Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
1️⃣ Why should it be added? What are the benefits of this change?
Many users raised the need to upgrade to PHPOffice/PHPSpreadsheet v2 or v4 for extended support from upstream library and compatibility with future PHP versions. See #4263
2️⃣ Does it contain multiple, unrelated changes? Please separate the PRs out.
CI changes, adjusted other dependencies and replaced legacy model factories with Laravel 8+ syntax.
3️⃣ Does it include tests, if possible?
Yes
4️⃣ Any drawbacks? Possible breaking changes?
Breaking changes:
ValueBinderwhen reading values - only when storing valuesPHPSpreadsheet v2 changed the logic when reading specific sheets only, breakingSee Option to Create Blank Sheet If LoadSheetsOnly Doesn't Find Any PHPOffice/PhpSpreadsheet#4618WithMultipleSheetsTesterror handling. Temporarily removingsetLoadSheetsOnlycall from theReaderfor now.Above broken features' tests were temporarily marked as skipped, hence WIP tag.
5️⃣ Mark the following tasks as done:
6️⃣ Thanks for contributing! 🙌