Appending rich text to a rich text object..

Topics: Developer Forum, User Forum
Jul 16, 2012 at 2:02 PM

I am new to PHPExcel and I try to create a rich text cell and it works fine. Now I want to append to a rich text and I get the problem, that when I try to enhance my first text (which comes anywhere from a function call and I do not have the previos specification) the formats are lost.

Is there a solution to get the "bold" text to the second RichtText object and keep the bold format ?

Thank you all for your help !

OS: Windows (XAMPP)  Apache/2.2.21 (Win32)
PHP Version 5.3.8

Short example :

$objRichText = new PHPExcel_RichText();
$objRichText->createText("This text is ");
$objBold  = $objRichText->createTextRun("bold ");
$objRichText->createText(" or so ");

// Rich Text based on $objRichText !
$objRichText1 = new PHPExcel_RichText();
$objBig = $objRichText1->createTextRun(" and also big ");
$objRichText1->createText(" or not ");

Jul 17, 2012 at 6:08 PM

The getRichTextElements() method of the PHPExcel_RichText object will return an array of PHPExcel_RichText_TextElement objects that can be individually modified "in situ", then reset in the original PHPExcel_RichText object using its setRichTextElements() method, passing back the full array.