-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Cell.php: Passing null to parameter #1 ($string) of type string is deprecated #3613
Comments
It would be helpful if you could upload the failing spreadsheet so that we can verify the problem and confirm that any fix that we make solves it. |
The Excel file I used will generate the same error during the PHP 8.2.6 test. $Reader = $path_info['extension'] === 'xls' ? new Xls() : new Xlsx(); |
Thank you for the sample file. I am not sure what makes your spreadsheet so "special", but I definitely duplicate your problem. |
As a workaround, you should be able to avoid the error with: $Writer->setPreCalculateFormulas(false); In the meantime, there seem to be at least 2 different problems associated with your spreadsheet. The first, dealing with the null value, is easy to deal with, and I will probably have something ready in the next few days. The other problem is that you have extremely complicated formulas, and the Calculation Engine, although it does not throw an exception, is unable to handle some of them correctly. I think it is likely that this inability is what is causing the unexpected null value to appear in the first place. Fixing that part of this problem is probably very difficult. |
Thanks for your reply. The null issue was caused by a change in the new version of PHP. |
The overall problem is described in issue PHPOffice#3613. This PR represents only a partial solution. Very complicated formulas are resulting in calls to string functions using null arguments, which is deprecated in recent Php releases. In fact, there are many such deprecations for the spreadsheet in question. Eliminating the deprecations is easy. However, the result of the calculation is, for many cells, 0 rather than what Excel determines it should be. This can be overlooked to a certain extent, because Excel will recalculate when the spreadsheet is opened, so loading and saving the spreadsheet in question will result in a spreadsheet which looks okay when it is opened in Excel. Resolving the incorrect calculation in PhpSpreadsheet would be nice, so I'm leaving the issue open, but that looks too complicated for me to get a toehold.
PR 3617 should eliminate the exceptions. It does not fix the incorrect internal calculations, which may or may not be adequate for your use case. I have used the debugging features available in PhpSpreadsheet, and cannot even see where it's going wrong, let alone how. Disabling branch pruning is a suggestion that has sometimes worked for Calculation problems, but it not only does not succeed here, it causes a new exception. |
The overall problem is described in issue #3613. This PR represents only a partial solution. Very complicated formulas are resulting in calls to string functions using null arguments, which is deprecated in recent Php releases. In fact, there are many such deprecations for the spreadsheet in question. Eliminating the deprecations is easy. However, the result of the calculation is, for many cells, 0 rather than what Excel determines it should be. This can be overlooked to a certain extent, because Excel will recalculate when the spreadsheet is opened, so loading and saving the spreadsheet in question will result in a spreadsheet which looks okay when it is opened in Excel. Resolving the incorrect calculation in PhpSpreadsheet would be nice, so I'm leaving the issue open, but that looks too complicated for me to get a toehold.
This is:
php 8.2.6 + PhpSpreadsheet 1.28.0
my project , recently upgraded php 7.4 to 8.4, frequent errors occur when reading excel, but not found in old php 7.4
warning tips:
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php
line: 393
msg: aa!N4 -> bb!O4 -> strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated
It may be an adaptation issue to the new environment. hope can be compatible it. thank you!
What is the expected behavior?
What is the current behavior?
What are the steps to reproduce?
What features do you think are causing the issue
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
Which versions of PhpSpreadsheet and PHP are affected?
The text was updated successfully, but these errors were encountered: