diff --git a/Classes/PHPExcel/ReferenceHelper.php b/Classes/PHPExcel/ReferenceHelper.php index e4aa9d8b0..90277c257 100644 --- a/Classes/PHPExcel/ReferenceHelper.php +++ b/Classes/PHPExcel/ReferenceHelper.php @@ -762,9 +762,13 @@ public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCo } } 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)); } }