From 0d1ff5b95fc63f1073f9b896f9a3981d36d927d6 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Tue, 28 Feb 2017 10:50:22 +0900 Subject: [PATCH] Better exception message for new Excel functions Closes https://github.com/PHPOffice/PHPExcel/issues/1136 --- src/PhpSpreadsheet/Calculation.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/PhpSpreadsheet/Calculation.php b/src/PhpSpreadsheet/Calculation.php index 930bf9ea..8dc957d3 100644 --- a/src/PhpSpreadsheet/Calculation.php +++ b/src/PhpSpreadsheet/Calculation.php @@ -3764,6 +3764,11 @@ class Calculation } elseif (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $token, $matches)) { $namedRange = $matches[6]; $this->debugLog->writeDebugLog('Evaluating Named Range ', $namedRange); + + if (substr($namedRange, 0, 6) === '_xlfn.') { + return $this->raiseFormulaError("undefined named range / function '$token'"); + } + $cellValue = $this->extractNamedRange($namedRange, ((null !== $pCell) ? $pCellWorksheet : null), false); $pCell->attach($pCellParent); $this->debugLog->writeDebugLog('Evaluation Result for named range ', $namedRange, ' is ', $this->showTypeDetails($cellValue));