Fix Xlsx loaded an extra empty comment for each real comment
Fixes #375 Closes #420
This commit is contained in:
parent
c723833d6f
commit
7e9f43bf5b
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Functional;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
class CommentsTest extends AbstractFunctional
|
||||
{
|
||||
public function providerFormats()
|
||||
{
|
||||
return [
|
||||
['Html'],
|
||||
['Xlsx'],
|
||||
['Ods'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test load file with comment in sheet to load proper
|
||||
* count of comments in correct coords.
|
||||
*
|
||||
* @dataProvider providerFormats
|
||||
*
|
||||
* @param $format
|
||||
*/
|
||||
public function testComments($format)
|
||||
{
|
||||
$spreadsheet = new Spreadsheet();
|
||||
|
||||
$spreadsheet->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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue