diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e431310..9ed3d06d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Subtotal 9 in a group that has other subtotals 9 exclude the totals of the other subtotals in the range - [#332](https://github.com/PHPOffice/PhpSpreadsheet/issues/332) - `Helper\Html` support UTF-8 HTML input - [#444](https://github.com/PHPOffice/PhpSpreadsheet/issues/444) +- Xlsx loaded an extra empty comment for each real comment - [#375](https://github.com/PHPOffice/PhpSpreadsheet/issues/375) ## [1.2.1] - 2018-04-10 diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 1ba4ce89..e32be775 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -1433,7 +1433,7 @@ class Xlsx extends BaseReader if (($column !== null) && ($row !== null)) { // Set comment properties - $comment = $docSheet->getCommentByColumnAndRow((string) $column, $row + 1); + $comment = $docSheet->getCommentByColumnAndRow($column + 1, $row + 1); $comment->getFillColor()->setRGB($fillColor); // Parse style diff --git a/tests/PhpSpreadsheetTests/Functional/CommentsTest.php b/tests/PhpSpreadsheetTests/Functional/CommentsTest.php new file mode 100644 index 00000000..a394c967 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Functional/CommentsTest.php @@ -0,0 +1,44 @@ +getActiveSheet()->getCell('E10')->setValue('Comment'); + $spreadsheet->getActiveSheet() + ->getComment('E10') + ->getText() + ->createText('Comment to test'); + + $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format); + + $commentsLoaded = $reloadedSpreadsheet->getSheet(0)->getComments(); + self::assertCount(1, $commentsLoaded); + + $commentCoordinate = key($commentsLoaded); + self::assertSame('E10', $commentCoordinate); + } +}