Skip to content

Commit

Permalink
Html Reader Comments (#2235)
Browse files Browse the repository at this point in the history
* Html Reader Comments

See issue #2234. Html Reader processes Comment as comment, then processes it as part of cell contents. Change to only do the first. Comment Test checks that comment read by Html Reader is okay, but neglects to check the value of the cell to which the comment is attached. Added that check.

* Disconnect Worksheets

... at end of test.
  • Loading branch information
oleibman authored Aug 5, 2021
1 parent 0cd20f3 commit de230fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/PhpSpreadsheet/Reader/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,9 @@ private function processDomElementSpanEtc(Worksheet $sheet, int &$row, string &$
$sheet->getComment($column . $row)
->getText()
->createTextRun($child->textContent);
} else {
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
}
$this->processDomElement($child, $sheet, $row, $column, $cellContent);

if (isset($this->formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
Expand Down
5 changes: 4 additions & 1 deletion tests/PhpSpreadsheetTests/Functional/CommentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ public function testComments($format): void

$commentCoordinate = key($commentsLoaded);
self::assertSame('E10', $commentCoordinate);
self::assertSame('Comment', $sheet->getCell('E10')->getValue());
$comment = $commentsLoaded[$commentCoordinate];
self::assertEquals('Comment to test', (string) $comment);
self::assertSame('Comment to test', (string) $comment);
$commentClone = clone $comment;
self::assertEquals($comment, $commentClone);
self::assertNotSame($comment, $commentClone);
Expand All @@ -51,5 +52,7 @@ public function testComments($format): void
$comment->setAlignment(Alignment::HORIZONTAL_RIGHT);
self::assertEquals(Alignment::HORIZONTAL_RIGHT, $comment->getAlignment());
}
$spreadsheet->disconnectWorksheets();
$reloadedSpreadsheet->disconnectWorksheets();
}
}

0 comments on commit de230fa

Please sign in to comment.