From eb9522dc4ffef9e68c9cced3d2e6de3375cbccb5 Mon Sep 17 00:00:00 2001 From: Jens Hassler Date: Wed, 23 Oct 2019 16:33:29 +0200 Subject: [PATCH] quick & dirty fix for PhpSpreadsheet issue #1215 -- needs rework! --- src/PhpSpreadsheet/Calculation/Calculation.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 6358866dde..f0d410db64 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -3664,8 +3664,15 @@ private function _parseFormula($formula, Cell $pCell = null) $val = $rangeWS2 . $endRowColRef . $val; } elseif ((ctype_alpha($startRowColRef)) && (ctype_alpha($val)) && (strlen($startRowColRef) <= 3) && (strlen($val) <= 3)) { - // Column range - $endRowColRef = ($pCellParent !== null) ? $pCellParent->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007 + // Column range + $refSheet = $pCellParent; + + // see https://github.com/PHPOffice/PhpSpreadsheet/issues/1215 + $rangeSheetName = \str_replace('!', '', $rangeWS1); + if ($rangeSheetName !== $pCellParent->getTitle()) { + $refSheet = $pCell->getWorksheet()->getParent()->getSheetByName($rangeSheetName); + } + $endRowColRef = ($pCellParent !== null) ? $refSheet->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007 $output[count($output) - 1]['value'] = $rangeWS1 . strtoupper($startRowColRef) . '1'; $val = $rangeWS2 . $val . $endRowColRef; }