'PHPWord add text / line break in addCell
I'm looking for a way to add a line break for a text within a cell.
I have 2 variables, $FirstName = 'Hello'; and $LastName = 'World'. I want to make it like :
Hello
World
The value for styles are :
$StyleCell = array('borderTopSize'=>8, 'borderLeftSize'=>8, 'borderRightSize'=>8);
$StyleText = array('size' => 10, 'bold' => true, 'valign' => 'center', 'align' => 'left');
I tried $table->addCell(4000, $StyleCell)->addText($FirstName. PHP_EOL . $LastName , $StyleText); but it only gives me Hello World in the cell. Which it did not work.
Anybody know knows what should I do for I tried $table->addCell(4000, $StyleCell)->addText($FirstName. /*?? What should I do ???*/ . $LastName, $StyleText); so it will become like :
Hello
World
I also tried ""\r\n"" or "\n" also did not work.
I'm using PHPWord 0.13.0
Solution 1:[1]
You can use '<w:br />' to break line.
$table->addCell(4000, $StyleCell)->addText($FirstName <w:br />$LastName , $StyleText);
For this example, the word file show:
$FirstName
$LastName
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | luis urdaneta |
