Problem when cell has font style

Topics: Developer Forum
Apr 24, 2012 at 10:58 AM

Hello.

When i use some style in cell like color, font size,... then an error returned among the cell value.

I use PHPExcel in this way:

require_once 'include/excel/PHPExcel/IOFactory.php';
$objReader = PHPExcel_IOFactory::createReader('Excel5');//use excel5
$objPHPExcel = $objReader->load($_FILES['excelfile']['tmp_name']);
$FAValue = ($objPHPExcel->getActiveSheet()->getCell('A'.$i)->getvalue());

The returened value to $FAValue will be:

__PHP_Incomplete_Class::__set_state(array(
'__PHP_Incomplete_Class_Name' => 'PHPExcel_RichText',
'_richTextElements' =>
array (
0 =>
__PHP_Incomplete_Class::__set_state(array(
'__PHP_Incomplete_Class_Name' => 'PHPExcel_RichText_TextElement',
 '_text' => 'dsfsdf ',
)),
1 =>
__PHP_Incomplete_Class::__set_state(array(
'__PHP_Incomplete_Class_Name' => 'PHPExcel_RichText_Run',
'_font' =>
__PHP_Incomplete_Class::__set_state(array(
'__PHP_Incomplete_Class_Name' => 'PHPExcel_Style_Font',
'_name' => 'Arial',
'_size' => 10,
'_bold' => true,
'_italic' => false,
'_superScript' => false,
'_subScript' => false,
'_underline' => 'none',
'_strikethrough' => false,
'_color' =>
__PHP_Incomplete_Class::__set_state(array(
'__PHP_Incomplete_Class_Name' => 'PHPExcel_Style_Color',
'_argb' => 'FF000000',
'_isSupervisor' => false,
'_parent' => NULL,
'_parentPropertyName' => NULL,
)),
'_parentPropertyName' => NULL,
'_isSupervisor' => false,
'_parent' => NULL,
'colorIndex' => 32767,
)),
 '_text' => 'sdfsdf',



Thanks in Advance

Coordinator
Apr 24, 2012 at 5:54 PM

This isn't quite the same of styling of a cell.... it's actually rich text styling of the cell content: test to see if $FAValue is an instance of a PHPExcel_RichText object, and if so then use the getPlainText() method (or simply cast to string, as PHPExcel_RichText has a magic __toString() method).

 

Apr 25, 2012 at 2:45 PM
MarkBaker wrote:

This isn't quite the same of styling of a cell.... it's actually rich text styling of the cell content: test to see if $FAValue is an instance of a PHPExcel_RichText object, and if so then use the getPlainText() method (or simply cast to string, as PHPExcel_RichText has a magic __toString() method).

 

Thanks, This method solved my problem.