Fix row/column range references against a different worksheet (#1224)
This commit is contained in:
parent
d088f47c7c
commit
429a34cb14
|
@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Formula Parser: Wrong line count for stuff like "MyOtherSheet!A:D" [#1215](https://github.com/PHPOffice/PhpSpreadsheet/issues/1215)
|
||||||
- Call garbage collector after removing a column to prevent stale cached values
|
- Call garbage collector after removing a column to prevent stale cached values
|
||||||
- Trying to remove a column that doesn't exist deletes the latest column
|
- Trying to remove a column that doesn't exist deletes the latest column
|
||||||
|
|
||||||
|
|
|
@ -3647,6 +3647,7 @@ class Calculation
|
||||||
if ($testPrevOp !== null && $testPrevOp['value'] === ':') {
|
if ($testPrevOp !== null && $testPrevOp['value'] === ':') {
|
||||||
$startRowColRef = $output[count($output) - 1]['value'];
|
$startRowColRef = $output[count($output) - 1]['value'];
|
||||||
[$rangeWS1, $startRowColRef] = Worksheet::extractSheetTitle($startRowColRef, true);
|
[$rangeWS1, $startRowColRef] = Worksheet::extractSheetTitle($startRowColRef, true);
|
||||||
|
$rangeSheetRef = $rangeWS1;
|
||||||
if ($rangeWS1 != '') {
|
if ($rangeWS1 != '') {
|
||||||
$rangeWS1 .= '!';
|
$rangeWS1 .= '!';
|
||||||
}
|
}
|
||||||
|
@ -3656,16 +3657,20 @@ class Calculation
|
||||||
} else {
|
} else {
|
||||||
$rangeWS2 = $rangeWS1;
|
$rangeWS2 = $rangeWS1;
|
||||||
}
|
}
|
||||||
|
$refSheet = $pCellParent;
|
||||||
|
if ($rangeSheetRef !== $pCellParent->getTitle()) {
|
||||||
|
$refSheet = $pCell->getWorksheet()->getParent()->getSheetByName($rangeSheetRef);
|
||||||
|
}
|
||||||
if ((is_int($startRowColRef)) && (ctype_digit($val)) &&
|
if ((is_int($startRowColRef)) && (ctype_digit($val)) &&
|
||||||
($startRowColRef <= 1048576) && ($val <= 1048576)) {
|
($startRowColRef <= 1048576) && ($val <= 1048576)) {
|
||||||
// Row range
|
// Row range
|
||||||
$endRowColRef = ($pCellParent !== null) ? $pCellParent->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007
|
$endRowColRef = ($refSheet !== null) ? $refSheet->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007
|
||||||
$output[count($output) - 1]['value'] = $rangeWS1 . 'A' . $startRowColRef;
|
$output[count($output) - 1]['value'] = $rangeWS1 . 'A' . $startRowColRef;
|
||||||
$val = $rangeWS2 . $endRowColRef . $val;
|
$val = $rangeWS2 . $endRowColRef . $val;
|
||||||
} elseif ((ctype_alpha($startRowColRef)) && (ctype_alpha($val)) &&
|
} elseif ((ctype_alpha($startRowColRef)) && (ctype_alpha($val)) &&
|
||||||
(strlen($startRowColRef) <= 3) && (strlen($val) <= 3)) {
|
(strlen($startRowColRef) <= 3) && (strlen($val) <= 3)) {
|
||||||
// Column range
|
// Column range
|
||||||
$endRowColRef = ($pCellParent !== null) ? $pCellParent->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007
|
$endRowColRef = ($refSheet !== null) ? $refSheet->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007
|
||||||
$output[count($output) - 1]['value'] = $rangeWS1 . strtoupper($startRowColRef) . '1';
|
$output[count($output) - 1]['value'] = $rangeWS1 . strtoupper($startRowColRef) . '1';
|
||||||
$val = $rangeWS2 . $val . $endRowColRef;
|
$val = $rangeWS2 . $val . $endRowColRef;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue