First value of cells field with RichText is not read correctly

Topics: Developer Forum, User Forum
Mar 30, 2010 at 4:07 PM


I am using PHP 5.2.10 along with PHPExcel 1.7.2;

I noticed the following behaviour, which seems to be wrong:

I have the following Excel 5 cell: <red font>Text 1</red font><black>Text 2</black><red font>Text 3</red font> (the tags are not actually in the cell, just to mention that I have Text 1 in red color and so on).

When I go through the cells, Text 1 appears as PHPExcel_RichText_TextElement (which is to bad because I cannot access getfont() and find out that the text is red) whereas Text 2 and Text3 are properly marked as PHPExcel_RichText_Run where I can access all the good methods.

Please tell me if you have a solution so that I can access the text color of the first element.



Mar 31, 2010 at 3:02 AM

Instead of this:

<red font>Text 1</red font><black>Text 2</black><red font>Text 3</red font>

It is likely that you really have this:
<cell red font>
Text 1<black>Text 2</black><red font>Text 3</red font>
</cell red font>

Although they will look the same when you open the file in Excel, they aren't.

In the second example, you have to inspect the cell style to find out that the "Text 1" is red.

Mar 31, 2010 at 7:48 AM

Hello koyama,

Thank you for your answer; it is clearer now.

So my next question is: how can I access a cell's font ? I tried a dummy $cell->getFont() by this is not implemented.

Thanks again,



Mar 31, 2010 at 8:29 AM

Ok I got it. THanks