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

Unsupported operand types: string + string in date format (PHP 8.x) #4249

Closed
7 tasks
alaindev opened this issue Nov 29, 2024 · 3 comments · Fixed by #4351
Closed
7 tasks

Unsupported operand types: string + string in date format (PHP 8.x) #4249

alaindev opened this issue Nov 29, 2024 · 3 comments · Fixed by #4351

Comments

@alaindev
Copy link

This is:

- [X ] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

detect returned string when calling fromString then skip operation
(line 132) $value = DateTimeExcel\DateValue::fromString($value) + DateTimeExcel\TimeValue::fromString($value);

What is the current behavior?

string+string is an issue in PHP 8.x
Fatal error: Uncaught TypeError: Unsupported operand types: string + string in C:\Program Files\EasyPHP-Devserver-17\eds-www\aplitec\includes\modules\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\TextData\Format.php:132

What are the steps to reproduce?

save("crash.xlsx"); ?>

If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.

What features do you think are causing the issue

  • Reader
  • [ X] Writer
  • Styles
  • Data Validations
  • Formula Calculations
  • Charts
  • AutoFilter
  • Form Elements

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

DATE Cell formatting when date cell is still a keyword and not yet a valid date!

Which versions of PhpSpreadsheet and PHP are affected? PHP >= 8.0

BUG_PHPSpreadsheet_PHP8_DATE.xlsx

@alaindev
Copy link
Author

test code is :

save("crash.xlsx"); ?>

@oleibman
Copy link
Collaborator

Sorry, I don't even understand what your spreadsheet contains. C2 seems to contain [onload.datecalcullong]. Is that what it is supposed to contain? B4 seems to contain ="Crash on au "&TEXT(C2,"jj/mm/aaaa"), which Excel evaluates as Crash on [onload.datecalcullong]. PhpSpreadsheet evaluates it as a #VALUE error (and it does not throw an exception when I load and save). Possibly this is locale-related - I'll need to do some research about that. But, while I'm doing that, it would be helpful to know how you expect this to behave.

@oleibman
Copy link
Collaborator

oleibman commented Feb 8, 2025

It would be really helpful to know that you're not on the current release when you report a problem. You must be on 1.29.*. This problem was fixed by PR #3898, in response to some apparently good advice from Phpstan. The fix first became part of a release with 2.1.0. We are not able to backport most fixes to non-current releases. However, I will change this in the release129 branch. Since we just had a release yesterday, it probably won't be part of an official release for at least a few weeks.

oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Feb 10, 2025
Fix PHPOffice#4249. Technically speaking, only the 1.29 branch needs fixing, and only for TEXT. It was fixed for the other branches by PR PHPOffice#3898. However, in adding test cases for the fix, it became apparent that PhpSpreadsheet's parsing in TIMEVALUE (which is called from TEXT in the original issue) did not really match Excel's. There are probably still edge cases where it doesn't, but, in the absence of a spec for how it operates, this will do for now.

We do not usually backport fixes from the master branch. Because this is more of a forward port from the earlier branch, there is an equivalent PR for each active branch.
oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Feb 10, 2025
Fix PHPOffice#4249. Technically speaking, only the 1.29 branch needs fixing, and only for TEXT. It was fixed for the other branches by PR PHPOffice#3898. However, in adding test cases for the fix, it became apparent that PhpSpreadsheet's parsing in TIMEVALUE (which is called from TEXT in the original issue) did not really match Excel's. There are probably still edge cases where it doesn't, but, in the absence of a spec for how it operates, this will do for now.

We do not usually backport fixes from the master branch. Because this is more of a forward port from the earlier branch, there is an equivalent PR for each active branch.
oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Feb 10, 2025
Fix PHPOffice#4249. Technically speaking, only the 1.29 branch needs fixing, and only for TEXT. It was fixed for the other branches by PR PHPOffice#3898. However, in adding test cases for the fix, it became apparent that PhpSpreadsheet's parsing in TIMEVALUE (which is called from TEXT in the original issue) did not really match Excel's. There are probably still edge cases where it doesn't, but, in the absence of a spec for how it operates, this will do for now.

We do not usually backport fixes from the master branch. Because this is more of a forward port from the earlier branch, there is an equivalent PR for each active branch.
oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Feb 10, 2025
Fix PHPOffice#4249. Technically speaking, only the 1.29 branch needs fixing, and only for TEXT. It was fixed for the other branches by PR PHPOffice#3898. However, in adding test cases for the fix, it became apparent that PhpSpreadsheet's parsing in TIMEVALUE (which is called from TEXT in the original issue) did not really match Excel's. There are probably still edge cases where it doesn't, but, in the absence of a spec for how it operates, this will do for now.

We do not usually backport fixes from the master branch. Because this is more of a forward port from the earlier branch, there is an equivalent PR for each active branch.
oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Feb 10, 2025
Fix PHPOffice#4249. Technically speaking, only the 1.29 branch needs fixing, and only for TEXT. It was fixed for the other branches by PR PHPOffice#3898. However, in adding test cases for the fix, it became apparent that PhpSpreadsheet's parsing in TIMEVALUE (which is called from TEXT in the original issue) did not really match Excel's. There are probably still edge cases where it doesn't, but, in the absence of a spec for how it operates, this will do for now.

We do not usually backport fixes from the master branch. Because this is more of a forward port from the earlier branch, there is an equivalent PR for each active branch.
oleibman added a commit that referenced this issue Feb 11, 2025
* Fix TEXT and TIMEVALUE Functions 1.29 Branch

Fix #4249. Technically speaking, only the 1.29 branch needs fixing, and only for TEXT. It was fixed for the other branches by PR #3898. However, in adding test cases for the fix, it became apparent that PhpSpreadsheet's parsing in TIMEVALUE (which is called from TEXT in the original issue) did not really match Excel's. There are probably still edge cases where it doesn't, but, in the absence of a spec for how it operates, this will do for now.

We do not usually backport fixes from the master branch. Because this is more of a forward port from the earlier branch, there is an equivalent PR for each active branch.

* Update Changelog
oleibman added a commit that referenced this issue Feb 11, 2025
Fix #4249. Technically speaking, only the 1.29 branch needs fixing, and only for TEXT. It was fixed for the other branches by PR #3898. However, in adding test cases for the fix, it became apparent that PhpSpreadsheet's parsing in TIMEVALUE (which is called from TEXT in the original issue) did not really match Excel's. There are probably still edge cases where it doesn't, but, in the absence of a spec for how it operates, this will do for now.

We do not usually backport fixes from the master branch. Because this is more of a forward port from the earlier branch, there is an equivalent PR for each active branch.
oleibman added a commit that referenced this issue Feb 11, 2025
Fix #4249. Technically speaking, only the 1.29 branch needs fixing, and only for TEXT. It was fixed for the other branches by PR #3898. However, in adding test cases for the fix, it became apparent that PhpSpreadsheet's parsing in TIMEVALUE (which is called from TEXT in the original issue) did not really match Excel's. There are probably still edge cases where it doesn't, but, in the absence of a spec for how it operates, this will do for now.

We do not usually backport fixes from the master branch. Because this is more of a forward port from the earlier branch, there is an equivalent PR for each active branch.
oleibman added a commit that referenced this issue Feb 11, 2025
Fix #4249. Technically speaking, only the 1.29 branch needs fixing, and only for TEXT. It was fixed for the other branches by PR #3898. However, in adding test cases for the fix, it became apparent that PhpSpreadsheet's parsing in TIMEVALUE (which is called from TEXT in the original issue) did not really match Excel's. There are probably still edge cases where it doesn't, but, in the absence of a spec for how it operates, this will do for now.

We do not usually backport fixes from the master branch. Because this is more of a forward port from the earlier branch, there is an equivalent PR for each active branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants