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

Consequetive "=" in a value passed taken as datatype FORMULA which throws an error. #1310

Closed
jaiminmoslake7020 opened this issue Jan 10, 2020 · 2 comments · Fixed by #4073
Closed

Comments

@jaiminmoslake7020
Copy link

This is:

- [Y] 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?

Assume a cell value is "=============".
It considers datatype for this "FORMULA" which is wrong and throws error.
It should consider it as STRING.

version 0.2.9 PHPOffice
src/PhpSpreadsheet/Cell/DefaultValueBinder.php LINE 58

    } elseif ($pValue[0] === '=' && strlen($pValue) > 1) {
            return DataType::TYPE_FORMULA;
    }

What is the current behavior?

Report Data!L1457 -> Formula Error: An unexpected error occured Traces:#0 
/var/app/current/_protected/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php(756): PhpOffice\PhpSpreadsheet\Cell\Cell->getCalculatedValue()

What are the steps to reproduce?

Just pass "===============" as any cell value.

Which versions of PhpSpreadsheet and PHP are affected?

version 0.2.9 PHPOffice

jaiminmoslake7020 added a commit to jaiminmoslake7020/PhpSpreadsheet that referenced this issue Jan 10, 2020
@stale
Copy link

stale bot commented Mar 10, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

@stale stale bot added the stale label Mar 10, 2020
@stale stale bot closed this as completed Mar 17, 2020
oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Jun 26, 2024
Fix PHPOffice#1310, which was closed as stale in 2020, but which I will now reopen. Supersedes PR PHPOffice#1311 (@jaiminmoslake7020), from which I will remove the stale label but leave closed. The issue and the PR were too limited  - they detected that the use of two equal signs at the start of a string made for an invalid formula, but there are variations, trivial and otherwise, which might also be detected. Using `setValue` with a string which starts with an equal sign will now attempt to parse (not evaluate) the formula; for certain situations in which the parser throws an exception, the string will be treated as a string rather than a formula. An example where it will still be treated as a formula is a 3D range reference, where the problem is not that it can't be parsed, but rather that the formula isn't supported (see unit test Calculation/Engine/RangeTest::test3dRangeEvaluation). Allowing such a formula might cause problems later on, but that is already what happens.

A string beginning with an equal sign but which isn't treated as a formula will automatically set the `quotePrefix` attribute to `true`; all other `setValue` attempts will set it to `false`. This avoids the problem of a lingering value causing problems later on.

It has long been a matter of discontent that setting a style can change the selected cells. A new method is added to `Worksheet`:
```php
applyStylesFromArray(string $coordinate, array $styleArray)
```
This will attempt to guarantee that the active sheet in the current spreadsheet, and the selected cells in the current worksheet, remain undisturbed after the call. The setting of `quotePrefix` above is the first use of the new method.
@oleibman
Copy link
Collaborator

Will be fixed by 4073.

@oleibman oleibman reopened this Jun 26, 2024
@stale stale bot removed the stale label Jun 26, 2024
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