phpexcel导入,出现PHPExcel_RichText Object解决办法

phpexcel,PHPExcel_RichText object在导入excel的时候会出现异常情况,有的问题出现PHPExcel_RichText object,错误代码如下

PHPExcel_RichText Object ( [_richTextElements:PHPExcel_RichText:private] => Array ( [0] => PHPExcel_RichText_Run Object ( [_font:PHPExcel_RichText_Run:private] => PHPExcel_Style_Font Object ( [_name:protected] => 細明體
 [_size:protected] => 12 [_bold:protected] => [_italic:protected] => [_superScript:protected] => [_subScript:protected] => [_underline:protected] => none [_strikethrough:protected] => [_color:protected] => PHPExcel_Style_Color Object ( [_argb:protected] => FF000000 [_parentPropertyName:protected] => [_isSupervisor:protected] => [_parent:protected] => ) [_isSupervisor:protected] => [_parent:protected] => [colorIndex] => 8 ) [_text:PHPExcel_RichText_TextElement:private] => 蜜糖皇后暖色胭脂 )
 [1] => PHPExcel_RichText_Run Object ( [_font:PHPExcel_RichText_Run:private] => PHPExcel_Style_Font Object ( [_name:protected] => Calibri [_size:protected] => 12 [_bold:protected] => [_italic:protected] => [_superScript:protected] => [_subScript:protected] => [_underline:protected] => none [_strikethrough:protected] => [_color:protected] => PHPExcel_Style_Color Object ( [_argb:protected] => FF000000 [_parentPropertyName:protected] => [_isSupervisor:protected] => [_parent:protected] => ) [_isSupervisor:protected] => [_parent:protected] => [colorIndex] => 8 ) [_text:PHPExcel_RichText_TextElement:private] => The Honey Queen Honeycomb Blusher ) ) )

为什么出现这个问题?我也不知道,度娘才知道是要“转文本格式”

import("Org.Util.PHPExcel");   // 这里不能漏掉
 import("Org.Util.PHPExcel.IOFactory");
$objReader = \PHPExcel_IOFactory::createReader('Excel5');
$objPHPExcel = $objReader->load($file_name,$encode='utf-8');

 /******   上面的代码可以不用看,下面的才是处理的重点     ******/
 // 获取excel C2的文本
$cell = $objPHPExcel->getActiveSheet()->getCell('C2')->getValue(); 
 // 开始格式化 
 if(is_object($cell))  $cell= $cell->__toString();

这是我浏览众多网页,提取最精简的解决办法;
thinkphp3.2和phpexcel导入
http://www.thinkphp.cn/code/2124.html
thinkphp3.2和phpexcel导入,出现PHPExcel_RichText object解决办法http://www.thinkphp.cn/code/2143.html
thinkphp3.2和phpexcel导出带生成图片完美案例http://www.thinkphp.cn/code/2112.html
thikphp高级交流群,群号 101766150

你可能感兴趣的:(phpexcel导入,出现PHPExcel_RichText Object解决办法)