mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-22 16:19:19 +00:00
Lookup ref further tests and examples (#1918)
* Extract LookupRef\INDEX() into index() method of LookupRef\Matrix class Additional tests * Bugfix for returning a column using INDEX() * Some improvements to ROW() and COLUMN() * Simplify some of the INDEX() logic, eliminating redundant code
This commit is contained in:
@@ -21,6 +21,7 @@ class IndexTest extends TestCase
|
||||
public function testINDEX($expectedResult, ...$args): void
|
||||
{
|
||||
$result = LookupRef::INDEX(...$args);
|
||||
// var_dump($result);
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ return [
|
||||
-1,
|
||||
],
|
||||
[
|
||||
'#VALUE!', // Expected
|
||||
'#REF!', // Expected
|
||||
// Input
|
||||
[
|
||||
'20' => ['R' => 1, 'S' => 3],
|
||||
@@ -63,6 +63,16 @@ return [
|
||||
2,
|
||||
10,
|
||||
],
|
||||
[
|
||||
'#REF!', // Expected
|
||||
// Input
|
||||
[
|
||||
'20' => ['R' => 1, 'S' => 3],
|
||||
'21' => ['R' => 2, 'S' => 4],
|
||||
],
|
||||
10,
|
||||
2,
|
||||
],
|
||||
[
|
||||
4, // Expected
|
||||
// Input
|
||||
@@ -87,4 +97,64 @@ return [
|
||||
'21' => ['R' => 2],
|
||||
],
|
||||
],
|
||||
[
|
||||
'Pears',
|
||||
[
|
||||
['Apples', 'Lemons'],
|
||||
['Bananas', 'Pears'],
|
||||
],
|
||||
2,
|
||||
2,
|
||||
],
|
||||
[
|
||||
'Bananas',
|
||||
[
|
||||
['Apples', 'Lemons'],
|
||||
['Bananas', 'Pears'],
|
||||
],
|
||||
2,
|
||||
1,
|
||||
],
|
||||
[
|
||||
3,
|
||||
[
|
||||
[4, 6],
|
||||
[5, 3],
|
||||
[6, 9],
|
||||
[7, 5],
|
||||
[8, 3],
|
||||
],
|
||||
5,
|
||||
2,
|
||||
],
|
||||
[
|
||||
[4 => [8, 3]],
|
||||
[
|
||||
[4, 6],
|
||||
[5, 3],
|
||||
[6, 9],
|
||||
[7, 5],
|
||||
[8, 3],
|
||||
],
|
||||
5,
|
||||
0,
|
||||
],
|
||||
[
|
||||
[
|
||||
[6],
|
||||
[3],
|
||||
[9],
|
||||
[5],
|
||||
[3],
|
||||
],
|
||||
[
|
||||
[4, 6],
|
||||
[5, 3],
|
||||
[6, 9],
|
||||
[7, 5],
|
||||
[8, 3],
|
||||
],
|
||||
0,
|
||||
2,
|
||||
],
|
||||
];
|
||||
|
||||
@@ -17,6 +17,13 @@ return [
|
||||
[[10], [11], [12]],
|
||||
'C10:D12',
|
||||
],
|
||||
[
|
||||
4,
|
||||
[
|
||||
4 => ['B' => 'B5', 'C' => 'C5', 'D' => 'D5'],
|
||||
5 => ['B' => 'B5', 'C' => 'C5', 'D' => 'D5'],
|
||||
],
|
||||
],
|
||||
[
|
||||
[[10], [11], [12]],
|
||||
'Sheet1!C10:C12',
|
||||
|
||||
Reference in New Issue
Block a user