From fcb794e2e210fd3d86cced37ad0105fe8da030ec Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Mon, 9 Dec 2013 23:45:45 +0000 Subject: [PATCH] Bugfix: Work Item GH-275 - Insert New Row/Column Before is not correctly updating formula references --- Classes/PHPExcel/ReferenceHelper.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Classes/PHPExcel/ReferenceHelper.php b/Classes/PHPExcel/ReferenceHelper.php index e4aa9d8b..90277c25 100644 --- a/Classes/PHPExcel/ReferenceHelper.php +++ b/Classes/PHPExcel/ReferenceHelper.php @@ -762,9 +762,13 @@ class PHPExcel_ReferenceHelper } } if ($adjustCount > 0) { - krsort($cellTokens); - krsort($newCellTokens); - // Update cell references in the formula + if ($pNumCols > 0 || $pNumRows > 0) { + krsort($cellTokens); + krsort($newCellTokens); + } else { + ksort($cellTokens); + ksort($newCellTokens); + } // Update cell references in the formula $formulaBlock = str_replace('\\','',preg_replace($cellTokens,$newCellTokens,$formulaBlock)); } }