Handle Ranges formatted as 3-d ranges, as long as the references are both to the same worksheet (#1540)
This commit is contained in:
parent
d57cce9aa9
commit
10a4a95d67
|
@ -3666,13 +3666,17 @@ class Calculation
|
||||||
if ($matches[2] == '') {
|
if ($matches[2] == '') {
|
||||||
// Otherwise, we 'inherit' the worksheet reference from the start cell reference
|
// Otherwise, we 'inherit' the worksheet reference from the start cell reference
|
||||||
// The start of the cell range reference should be the last entry in $output
|
// The start of the cell range reference should be the last entry in $output
|
||||||
$startCellRef = $output[count($output) - 1]['value'];
|
$rangeStartCellRef = $output[count($output) - 1]['value'];
|
||||||
preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/i', $startCellRef, $startMatches);
|
preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/i', $rangeStartCellRef, $rangeStartMatches);
|
||||||
if ($startMatches[2] > '') {
|
if ($rangeStartMatches[2] > '') {
|
||||||
$val = $startMatches[2] . '!' . $val;
|
$val = $rangeStartMatches[2] . '!' . $val;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return $this->raiseFormulaError('3D Range references are not yet supported');
|
$rangeStartCellRef = $output[count($output) - 1]['value'];
|
||||||
|
preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/i', $rangeStartCellRef, $rangeStartMatches);
|
||||||
|
if ($rangeStartMatches[2] !== $matches[2]) {
|
||||||
|
return $this->raiseFormulaError('3D Range references are not yet supported');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,20 @@ class RangeTest extends TestCase
|
||||||
['=COUNT(A1:C1,A3:C3,B1:C3)', 12],
|
['=COUNT(A1:C1,A3:C3,B1:C3)', 12],
|
||||||
['=SUM(A1:C1,A3:C3 B1:C3)', 23],
|
['=SUM(A1:C1,A3:C3 B1:C3)', 23],
|
||||||
['=COUNT(A1:C1,A3:C3 B1:C3)', 5],
|
['=COUNT(A1:C1,A3:C3 B1:C3)', 5],
|
||||||
|
['=SUM(Worksheet!A1:B3,Worksheet!A1:C2)', 48],
|
||||||
|
['=SUM(Worksheet!A1:Worksheet!B3,Worksheet!A1:Worksheet!C2)', 48],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test3dRangeEvaluation(): void
|
||||||
|
{
|
||||||
|
$workSheet = $this->spreadSheet->getActiveSheet();
|
||||||
|
$workSheet->setCellValue('E1', '=SUM(Worksheet!A1:Worksheet2!B3)');
|
||||||
|
|
||||||
|
$this->expectExceptionMessage('3D Range references are not yet supported');
|
||||||
|
$workSheet->getCell('E1')->getCalculatedValue();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providerNamedRangeEvaluation
|
* @dataProvider providerNamedRangeEvaluation
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue