Hello World Hello
World Hello
World '; $spreadsheet = (new Html())->loadFromString($html); $firstSheet = $spreadsheet->getSheet(0); $cellStyle = $firstSheet->getStyle('A1'); self::assertFalse($cellStyle->getAlignment()->getWrapText()); $cellStyle = $firstSheet->getStyle('A2'); self::assertTrue($cellStyle->getAlignment()->getWrapText()); $cellValue = $firstSheet->getCell('A2')->getValue(); self::assertStringContainsString("\n", $cellValue); $cellStyle = $firstSheet->getStyle('A3'); self::assertTrue($cellStyle->getAlignment()->getWrapText()); $cellValue = $firstSheet->getCell('A3')->getValue(); self::assertStringContainsString("\n", $cellValue); } public function testLoadInvalidString(): void { $this->expectException(ReaderException::class); $html = ''; $spreadsheet = (new Html())->loadFromString($html); $firstSheet = $spreadsheet->getSheet(0); $cellStyle = $firstSheet->getStyle('A1'); self::assertFalse($cellStyle->getAlignment()->getWrapText()); } public function testCanLoadFromStringIntoExistingSpreadsheet(): void { $html = '
Hello World
Hello
World
Hello
World
'; $reader = new Html(); $spreadsheet = $reader->loadFromString($html); $firstSheet = $spreadsheet->getSheet(0); $cellStyle = $firstSheet->getStyle('A1'); self::assertFalse($cellStyle->getAlignment()->getWrapText()); $cellStyle = $firstSheet->getStyle('A2'); self::assertTrue($cellStyle->getAlignment()->getWrapText()); $cellValue = $firstSheet->getCell('A2')->getValue(); self::assertStringContainsString("\n", $cellValue); $cellStyle = $firstSheet->getStyle('A3'); self::assertTrue($cellStyle->getAlignment()->getWrapText()); $cellValue = $firstSheet->getCell('A3')->getValue(); self::assertStringContainsString("\n", $cellValue); $reader->setSheetIndex(1); $html = '
Goodbye World
'; self::assertEquals(1, $spreadsheet->getSheetCount()); $spreadsheet = $reader->loadFromString($html, $spreadsheet); self::assertEquals(2, $spreadsheet->getSheetCount()); } }