From 45fb4d84c1d42fdc74dce3d5573759e2b45ec260 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Fri, 25 Feb 2011 22:57:22 +0000 Subject: [PATCH] Bugfix: Work item 15421 - PHPExcel_ReferenceHelper::insertNewBefore() is missing an 'Update worksheet: comments' section Solution, courtesy of MKunert git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@69421 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/ReferenceHelper.php | 8 ++++++++ Classes/PHPExcel/Worksheet.php | 13 +++++++++++++ changelog.txt | 1 + 3 files changed, 22 insertions(+) diff --git a/Classes/PHPExcel/ReferenceHelper.php b/Classes/PHPExcel/ReferenceHelper.php index 98819b2e..4ccc2b59 100644 --- a/Classes/PHPExcel/ReferenceHelper.php +++ b/Classes/PHPExcel/ReferenceHelper.php @@ -259,6 +259,14 @@ class PHPExcel_ReferenceHelper } } + // Update worksheet: comments + $aComments = $pSheet->getComments(); + $aNewComments = array(); // the new array of all comments + foreach ($aComments as $key => &$value) { + $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); + $aNewComments[$newReference] = $value; + } + $pSheet->setComments($aNewComments); // replace the comments array // Update worksheet: hyperlinks $aHyperlinkCollection = array_reverse($pSheet->getHyperlinkCollection(), true); diff --git a/Classes/PHPExcel/Worksheet.php b/Classes/PHPExcel/Worksheet.php index 1eed5ced..70ac3801 100644 --- a/Classes/PHPExcel/Worksheet.php +++ b/Classes/PHPExcel/Worksheet.php @@ -1941,6 +1941,19 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable return $this->_comments; } + /** + * Set comments array for the entire sheet. + * + * @param array of PHPExcel_Comment + * @return PHPExcel_Worksheet + */ + public function setComments($pValue = array()) + { + $this->_comments = $pValue; + + return $this; + } + /** * Get comment for cell * diff --git a/changelog.txt b/changelog.txt index 5bdd44ad..5a90160f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -67,6 +67,7 @@ Fixed in SVN: - Bugfix: (MBaker) Work item 15379 - Named ranges with dot don't get parsed properly - Bugfix: (MBaker) Work item 15096 - insertNewRowBefore fails to consistently update references - Bugfix: (MBaker) "i" is not a valid character for Excel date format masks (in isDateTimeFormatCode() method) +- Bugfix: (MKunert) Work item 15421 - PHPExcel_ReferenceHelper::insertNewBefore() is missing an 'Update worksheet: comments' section - General: (MBaker) Improved performance (speed), for building the Shared Strings table in the Excel2007 Writer. - General: (MBaker) Improved performance (speed), for PHP to Excel date conversions - General: (MBaker) Enhanced SheetViews element structures in the Excel2007 Writer for frozen panes.