Html Reader Comments (#2235)

* 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.
This commit is contained in:
oleibman 2021-08-05 08:40:13 -07:00 committed by GitHub
parent 0cd20f3099
commit de230fa899
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -345,8 +345,9 @@ class Html extends BaseReader
$sheet->getComment($column . $row) $sheet->getComment($column . $row)
->getText() ->getText()
->createTextRun($child->textContent); ->createTextRun($child->textContent);
} } else {
$this->processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
}
if (isset($this->formats[$child->nodeName])) { if (isset($this->formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);

View File

@ -40,8 +40,9 @@ class CommentsTest extends AbstractFunctional
$commentCoordinate = key($commentsLoaded); $commentCoordinate = key($commentsLoaded);
self::assertSame('E10', $commentCoordinate); self::assertSame('E10', $commentCoordinate);
self::assertSame('Comment', $sheet->getCell('E10')->getValue());
$comment = $commentsLoaded[$commentCoordinate]; $comment = $commentsLoaded[$commentCoordinate];
self::assertEquals('Comment to test', (string) $comment); self::assertSame('Comment to test', (string) $comment);
$commentClone = clone $comment; $commentClone = clone $comment;
self::assertEquals($comment, $commentClone); self::assertEquals($comment, $commentClone);
self::assertNotSame($comment, $commentClone); self::assertNotSame($comment, $commentClone);
@ -51,5 +52,7 @@ class CommentsTest extends AbstractFunctional
$comment->setAlignment(Alignment::HORIZONTAL_RIGHT); $comment->setAlignment(Alignment::HORIZONTAL_RIGHT);
self::assertEquals(Alignment::HORIZONTAL_RIGHT, $comment->getAlignment()); self::assertEquals(Alignment::HORIZONTAL_RIGHT, $comment->getAlignment());
} }
$spreadsheet->disconnectWorksheets();
$reloadedSpreadsheet->disconnectWorksheets();
} }
} }