mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-25 20:28:18 +00:00
e40438916f
Fix #1310, which was closed as stale in 2020, but which I will now reopen. Supersedes PR #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.
90 lines
1.1 KiB
PHP
90 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
return [
|
|
[
|
|
'null',
|
|
null,
|
|
],
|
|
[
|
|
'e',
|
|
'#NULL!',
|
|
],
|
|
[
|
|
'b',
|
|
false,
|
|
],
|
|
[
|
|
'b',
|
|
true,
|
|
],
|
|
[
|
|
's',
|
|
'FALSE',
|
|
],
|
|
[
|
|
's',
|
|
'TRUE',
|
|
],
|
|
[
|
|
's',
|
|
'',
|
|
],
|
|
[
|
|
's',
|
|
'ABC',
|
|
],
|
|
[
|
|
'n',
|
|
'123',
|
|
],
|
|
[
|
|
'n',
|
|
123,
|
|
],
|
|
[
|
|
'n',
|
|
0.123,
|
|
],
|
|
[
|
|
'n',
|
|
'-123',
|
|
],
|
|
[
|
|
'n',
|
|
'1.23E4',
|
|
],
|
|
[
|
|
'n',
|
|
'-1.23E4',
|
|
],
|
|
[
|
|
'n',
|
|
'1.23E-4',
|
|
],
|
|
[
|
|
's',
|
|
'000123',
|
|
],
|
|
[
|
|
'f',
|
|
'=123',
|
|
],
|
|
[
|
|
'e',
|
|
'#DIV/0!',
|
|
],
|
|
[
|
|
's',
|
|
'123456\n',
|
|
],
|
|
'Numeric that exceeds PHP MAX_INT Size' => [
|
|
's',
|
|
'1234567890123459012345689012345690',
|
|
],
|
|
'Issue 1310 Multiple = at start' => ['s', '======'],
|
|
'Issue 1310 Variant 1' => ['s', '= ====='],
|
|
'Issue 1310 Variant 2' => ['s', '=2*3='],
|
|
];
|