Set wrap text style when multiline string encountered

Fixes #10
If a cell contains a multiline string, "wrap text" style option should
automatically be set.
This commit is contained in:
Adrien Loison committed 2015-08-13 23:03:28 -07:00
1 parent 1c8934790d
commit c8ddcf5441
6 files changed
+102 -8

No files matched your search

@@ -206,6 +206,25 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('1', $cellDomElements[1]->getAttribute('s'));
}
/**
* @return void
*/
public function testAddRowWithStyleShouldApplyWrapTextIfCellContainsNewLine()
{
$fileName = 'test_add_row_with_style_should_apply_wrap_text_if_new_lines.xlsx';
$dataRows = [
["xlsx--11\nxlsx--11"],
['xlsx--21'],
];
$this->writeToXLSXFile($dataRows, $fileName, $this->defaultStyle);
$cellXfsDomElement = $this->getXmlSectionFromStylesXmlFile($fileName, 'cellXfs');
$xfElement = $cellXfsDomElement->getElementsByTagName('xf')->item(1);
$this->assertEquals(1, $xfElement->getAttribute('applyAlignment'));
$this->assertFirstChildHasAttributeEquals('1', $xfElement, 'alignment', 'wrapText');
}
/**
* @param array $allRows
* @param string $fileName