Source for file RichText.php
Documentation is available at RichText.php
* Copyright (c) 2006 - 2009 PHPExcel
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.6.5, 2009-01-05
/** PHPExcel_IComparable */
require_once 'PHPExcel/IComparable.php';
require_once 'PHPExcel/Cell.php';
/** PHPExcel_RichText_ITextElement */
require_once 'PHPExcel/RichText/ITextElement.php';
/** PHPExcel_RichText_TextElement */
require_once 'PHPExcel/RichText/TextElement.php';
/** PHPExcel_RichText_Run */
require_once 'PHPExcel/RichText/Run.php';
/** PHPExcel_Style_Font */
require_once 'PHPExcel/Style/Font.php';
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
* @var PHPExcel_RichText_ITextElement[]
* Create a new PHPExcel_RichText instance
* @param PHPExcel_Cell $pParent
public function __construct(PHPExcel_Cell $pCell = null)
// Add cell text and style
if ($this->_parent->getValue() != "") {
$objRun->setFont(clone $this->_parent->getParent()->getStyle($this->_parent->getCoordinate())->getFont());
* @param PHPExcel_RichText_ITextElement $pText Rich text element
public function addText(PHPExcel_RichText_ITextElement $pText = null)
* @param string $pText Text
* @return PHPExcel_RichText_TextElement
* @param string $pText Text
* @return PHPExcel_RichText_Run
// Loop trough all PHPExcel_RichText_ITextElement
$returnValue .= $text->getText();
* @return PHPExcel_RichText_ITextElement[]
* @param PHPExcel_RichText_ITextElement[] $pElements Array of elements
throw new Exception("Invalid PHPExcel_RichText_ITextElement[] array passed.");
* @param PHPExcel_Cell $value
public function setParent(PHPExcel_Cell $value) {
// Verify style information
$sheet = $this->_parent->getParent();
$cellFont = $sheet->getStyle($this->_parent->getCoordinate())->getFont();
if ($element->getFont()->getHashCode() == $sheet->getDefaultStyle()->getFont()->getHashCode()) {
if ($element->getFont()->getHashCode() != $cellFont->getHashCode()) {
$element->setFont(clone $cellFont);
* @return string Hash code
$hashElements .= $element->getHashCode();
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
* @return string Hash index
* Note that this index may vary during script execution! Only reliable moment is
* while doing a write of a workbook and when changes are not allowed.
* @param string $value Hash index
* Implement PHP __clone to create a deep clone, not just a shallow copy.
foreach ($vars as $key => $value) {
if ($key == '_parent') continue;
$this->$key = clone $value;
|