Your Location is: Home > Php

PHPWord add text / line break in addCell

From: Turkey View: 3749 Galvion 


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 :


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 :


I also tried ""\r\n"" or "\n" also did not work.

I'm using PHPWord 0.13.0

Best answer