From 8721f795fc4537b2bdf9daf93e3b52c4805a214d Mon Sep 17 00:00:00 2001 From: Ivan Stanojevic Date: Mon, 1 Mar 2021 12:33:35 +0100 Subject: [PATCH] Update ReferenceHelper.php (#1873) * Update ReferenceHelper for Defined Names --- src/PhpSpreadsheet/ReferenceHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index 13f7cf71b9..513f0a534c 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -608,7 +608,7 @@ public function insertNewBefore($pBefore, $pNumCols, $pNumRows, Worksheet $pShee // Update workbook: define names if (count($pSheet->getParent()->getDefinedNames()) > 0) { foreach ($pSheet->getParent()->getDefinedNames() as $definedName) { - if ($definedName->getWorksheet()->getHashCode() === $pSheet->getHashCode()) { + if ($definedName->getWorksheet() !== null && $definedName->getWorksheet()->getHashCode() === $pSheet->getHashCode()) { $definedName->setValue($this->updateCellReference($definedName->getValue(), $pBefore, $pNumCols, $pNumRows)); } }