Quantcast
Channel: PHPWord
Viewing all articles
Browse latest Browse all 450

New Post: Multiple addText in a table cell

$
0
0
Hi
I wish to add text in various colours to a table cell. So I define a table cell:
$WORD_table->addRow();
$cell=$WORD_table->addCell(9637,array('gridSpan' => 5));

And then in a loop do:

$cell->addText($bird,array('color'=>'red'));

where the colour changes according to some properties of the item I am adding. This works well EXCEPT that each item of text then appears as a new paragraph in the table cell, and I want then all to be in a single table cell.
So I did the following after the creation of $cell:

$textrun = $cell->createTextRun();

and then replaced the $cell->addText by $textrun->addText. This works well and is not covered in the documentation, so I just thought I would share this in case anyone has a similar problem!

Viewing all articles
Browse latest Browse all 450

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>