-
how to use richText in looping (for) . use in documentation not working. thanks. for ($i = 0; $i < count(array_keys($Data)); $i++) {
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I'm not sure exactly what you're trying to do here, because you could just as easily set the cell styles rather than using Rich Text; but what exactly is the problem that you're having? What do you expect? And what do you get? And what is |
Beta Was this translation helpful? Give feedback.
-
Then you need one rich text object that has two runs, one with the name and the styling, the second run with the age and no styling; and you write that rich text object to the cell... you're trying to concatenate a rich text object with plain text (which will result in a standard PHP string of plain text) and then write that to the cell But, a rich text object can contain a mixture of styled text and unstyled text $richText = new RichText();
$payable = $richText->createTextRun($Data[$i]->Name);
$payable->getFont()->setBold(true);
$payable->getFont()->setColor(new Color(Color::COLOR_DARKGREEN));
$richText->createText("\n" . $Data[$i]->Age); |
Beta Was this translation helpful? Give feedback.
Then you need one rich text object that has two runs, one with the name and the styling, the second run with the age and no styling; and you write that rich text object to the cell... you're trying to concatenate a rich text object with plain text (which will result in a standard PHP string of plain text) and then write that to the cell
A Excel cell can't contain both a plain text string and a rich text object, it can contain either plain text or rich text
But, a rich text object can contain a mixture of styled text and unstyled text