Prev IsRichText |
ExcelExplorer Manual |
Next IsPhonetic |
 |
(ExcelExplorer 4.0)
Returns rich text settings for the string, if any.
false array(EEDataRichText) RichText( )
Parameters
- None
Description
Text in the cell formatted by storing style info about whole cell.
But Excel have possibility to format individual part of the text in the cell.
This is called rich text formatting.
If you do not need to read rich text data you can still use
methods like UTF8() that will ignore rich text data and works with the whole string.
Note that this method can returns FALSE in the following cases:
- Cell contains non-text value.
- String contains no rich text parts - font from cell settings must applied instead.
- Erroneous data stored in the Excel file.
You should always check if returned value is valid array (not a FALSE) before accessing its elements (EEDataRichText objects).
Example of the rich text:
 |
A |
B |
C |
| 1 |
|
|
|
| 2 |
|
RedGreenBlue |
|
| 3 |
|
|
|
In the example above text in the cell B2 consists of 3 parts:
first contains string "Red" with bold red font,
second - bold underlined green string "Green" and the third - bold italic blue "Blue".
This method called for this cell will returns array of 3 elements of EEDataRichText objects that contains string part and the font used for the formatting corresponding part.
Print rich text data (output generated using worksheet that showed above)
<?php
if( ($rich = $ee->Cell(0,1,1)->Data()->RichText()) ) {
echo "Text consists of ".count($rich)." parts\n";
for( $i=0; $i<count($rich); $i++ ) {
echo 'Part '.($i+1).': ';
echo 'text "'.$rich[$i]->Data()->UTF8().'" ';
if( $rich[$i]->Font() ) {
echo 'formatted using font with index '.$rich[$i]->Font()->Index();
} else {
echo 'formatted using default cell font';
}
echo "\n";
}
} else {
echo 'Text not contains rich text parts';
}
?>
Will output: Text consists of 3 parts
Part 1: text "Red" formatted using font with index 5
Part 2: text "Blue" formatted using font with index 6
Part 3: text "Green" formatted using font with index 7
|