diff --git a/Classes/PHPExcel/ReferenceHelper.php b/Classes/PHPExcel/ReferenceHelper.php index 6fc96ecb..32b32784 100644 --- a/Classes/PHPExcel/ReferenceHelper.php +++ b/Classes/PHPExcel/ReferenceHelper.php @@ -68,6 +68,26 @@ class PHPExcel_ReferenceHelper protected function __construct() { } + private function cellSort($a, $b) { + list($ac,$ar) = sscanf($a,'%[A-Z]%d'); + list($bc,$br) = sscanf($b,'%[A-Z]%d'); + + if ($ar == $br) { + return strcasecmp(sprintf('%03s',$ac), sprintf('%03s',$bc)); + } + return ($ar < $br) ? -1 : 1; + } + + private function cellReverseSort($a, $b) { + list($ac,$ar) = sscanf($a,'%[A-Z]%d'); + list($bc,$br) = sscanf($b,'%[A-Z]%d'); + + if ($ar == $br) { + return 1 - strcasecmp(sprintf('%03s',$ac), sprintf('%03s',$bc)); + } + return ($ar < $br) ? 1 : -1; + } + /** * Insert a new column, updating all possible related data * @@ -274,9 +294,10 @@ class PHPExcel_ReferenceHelper $pSheet->setComments($aNewComments); // replace the comments array // Update worksheet: hyperlinks - $aHyperlinkCollection = $pNumCols > 0 || $pNumRows > 0 ? - array_reverse($pSheet->getHyperlinkCollection(), true) : - $pSheet->getHyperlinkCollection(); + $aHyperlinkCollection = $pSheet->getHyperlinkCollection(); + ($pNumCols > 0 || $pNumRows > 0) ? + uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) : + uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellSort')); foreach ($aHyperlinkCollection as $key => $value) { $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); if ($key != $newReference) { diff --git a/changelog.txt b/changelog.txt index bcdccbae..cfe17493 100644 --- a/changelog.txt +++ b/changelog.txt @@ -58,6 +58,7 @@ Fixed in develop branch for release v1.7.9: - Bugfix: (MBaker) - Add DROP TABLE in destructor for SQLite and SQLite3 cache controllers - Bugfix: (alexgann) Work item GH-154 - Fix merged-cell borders on HTML/PDF output - Bugfix: (Shanto) Work item GH-161 - Fix: Hyperlinks break when removing rows +- Bugfix: (neclimdul) Work item GH-166 - Fix Extra Table Row From Images and Charts --------------------------------------------------------------------------------