From dd7b0610e99bb708980b595d41ace5a3a5fce081 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Fri, 29 Apr 2011 13:44:27 +0000 Subject: [PATCH] Bugfix: Work item 15762 - INDIRECT() function doesn't work with named ranges git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@72460 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/Calculation/LookupRef.php | 14 +++++++++++++- changelog.txt | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Classes/PHPExcel/Calculation/LookupRef.php b/Classes/PHPExcel/Calculation/LookupRef.php index 7ebca4d9..bcf755fa 100644 --- a/Classes/PHPExcel/Calculation/LookupRef.php +++ b/Classes/PHPExcel/Calculation/LookupRef.php @@ -283,7 +283,19 @@ class PHPExcel_Calculation_LookupRef { if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress1, $matches)) || ((!is_null($cellAddress2)) && (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress2, $matches)))) { - return PHPExcel_Calculation_Functions::REF(); + + if (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $cellAddress1, $matches)) { + return PHPExcel_Calculation_Functions::REF(); + } + + if (strpos($cellAddress,'!') !== false) { + list($sheetName,$cellAddress) = explode('!',$cellAddress); + $pSheet = $pCell->getParent()->getParent()->getSheetByName($sheetName); + } else { + $pSheet = $pCell->getParent(); + } + + return PHPExcel_Calculation::getInstance()->extractNamedRange($cellAddress, $pSheet, False); } if (strpos($cellAddress,'!') !== false) { diff --git a/changelog.txt b/changelog.txt index 492d9abc..75185b78 100644 --- a/changelog.txt +++ b/changelog.txt @@ -32,6 +32,7 @@ Fixed in SVN: - Bugfix: (MBaker) Support for Excel functions whose return can be used as either a value or as a cell reference depending on its context within a formula - Bugfix: (gilles06) Work item 15707 - ini_set() call in Calculation class destructor - Bugfix: (MBaker) Work item 15786 - RangeToArray strange array keys +- Bugfix: (MBaker) Work item 15762 - INDIRECT() function doesn't work with named ranges - General: (MBaker) Work item 15405 - Two easy to fix Issues concerning PHPExcel_Token_Stack (l10n/UC) - General: (MBaker) Work item 15461 - Locale file paths not fit for windows