mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-25 15:28:20 +00:00
40f7cd00db
We have identical constants defined in several places, and use literals in others. We aren't consistent in checking limits. This PR makes the use of the constants in Cell/AddressRange the "official" source, deprecates all other constants, and substitutes the constants wherever literals are used. A number of different edge case tests are added. During testing, I discovered that `columnIndexFromString` correctly throws an exception for 4-character string, but allows `XFE` through `ZZZ`, all of which are also invalid. There are similar inconsistencies with related routines, and this PR attempts to make them operate consistently. One suprise is that throwing for `row=0` causes serious regression problems, so it continues to be permitted (but the high row limit is enforced). Further, Reference Helper sometimes dips into negative numbers, resulting in totally unexpected results (-1 affects column Z, -2 column Y, etc.). It is changed to ignore rows and columns outside the limits.
23 lines
904 B
PHP
23 lines
904 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
return [
|
|
'current row' => [3, 'omitted'],
|
|
'global name $E$2:$E$6' => [2, 'namedrangex'],
|
|
'global name $F$2:$H$2' => [2, 'namedrangey'],
|
|
'global name $F$4:$H$4' => [4, 'namedrange3'],
|
|
'local name $F$5:$H$5' => [5, 'namedrange5'],
|
|
'out of scope name' => ['#NAME?', 'localname'],
|
|
'qualified cell existing sheet' => [1, 'OtherSheet!A1'],
|
|
'qualified cell non-existent sheet' => [1, 'UnknownSheet!A1'],
|
|
'single cell absolute' => [7, '$C$7'],
|
|
'single cell relative' => [7, 'C7'],
|
|
'unknown name' => ['#NAME?', 'namedrange2'],
|
|
'unknown name as first part of range' => ['#NAME?', 'InvalidCell:A2'],
|
|
'unknown name as second part of range' => ['#NAME?', 'A2:InvalidCell'],
|
|
'qualified name' => [6, 'OtherSheet!localname'],
|
|
'last valid row' => [1048576, 'A1048576'],
|
|
'beyond last valid row' => ['#NAME?', 'A1048577'],
|
|
];
|