diff --git a/CHANGELOG.md b/CHANGELOG.md index f15a894f..0d029fe7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org). ## [Unreleased] +### Added + +- When <br> appears in a table cell, set the cell to wrap [Issue #1071](https://github.com/PHPOffice/PhpSpreadsheet/issues/1071) and [PR #1070](https://github.com/PHPOffice/PhpSpreadsheet/pull/1070) + ### Fixed - COUPNUM should not return zero when settlement is in the last period - [Issue #1020](https://github.com/PHPOffice/PhpSpreadsheet/issues/1020) and [PR #1021](https://github.com/PHPOffice/PhpSpreadsheet/pull/1021) diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 2e823f03..75db7591 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -374,8 +374,9 @@ class Html extends BaseReader // no break case 'br': if ($this->tableLevel > 0) { - // If we're inside a table, replace with a \n + // If we're inside a table, replace with a \n and set the cell to wrap $cellContent .= "\n"; + $sheet->getStyle($column . $row)->getAlignment()->setWrapText(true); } else { // Otherwise flush our existing content and move the row cursor on $this->flushCell($sheet, $column, $row, $cellContent); diff --git a/tests/PhpSpreadsheetTests/Reader/HtmlTest.php b/tests/PhpSpreadsheetTests/Reader/HtmlTest.php index f56030e0..415f562a 100644 --- a/tests/PhpSpreadsheetTests/Reader/HtmlTest.php +++ b/tests/PhpSpreadsheetTests/Reader/HtmlTest.php @@ -266,6 +266,39 @@ class HtmlTest extends TestCase unlink($filename); } + public function testCanApplyCellWrapping() + { + $html = '
Hello World | +
Hello World |
+
Hello World |
+