Problem Status: When you import Excel, it appears
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] = A[_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] [Honey Queen warm Rouge] [1] = = Phpexcel_richtext_run Object ([_font:phpexcel_richtext_run:Private] = = Phpexcel_style_font Object ([_name:protected] = Calibri [_size:protected] = A[_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)))
Solutions
Import"Org.Util.PHPExcel");//you can't miss it here .Import"Org.Util.PHPExcel.IOFactory"); $objReader= \phpexcel_iofactory::createreader ('Excel5'); $objPHPExcel= $objReader->load ($file _name, $encode ='Utf-8'); /** * * * The above code can not be looked at, the following is the focus of treatment * * **/ //get the text for Excel C2$cell = $objPHPExcel->getactivesheet ()->getcell ('C2'),GetValue (); //Start Formatting if(Is_object ($cell)) $cell = $cell->__tostring ();
Case reference $file _name= "Xxx.xls"
Publicfunction Excel ($file _name) {//$file _name= './upload/excel/123456.xls ';Import"Org.Util.PHPExcel");//you can't miss it here .Import"Org.Util.PHPExcel.IOFactory"); $objReader= \phpexcel_iofactory::createreader ('Excel5'); $objPHPExcel= $objReader->load ($file _name, $encode ='Utf-8'); $sheet= $objPHPExcel->getsheet (0); $highestRow= $sheet->gethighestrow ();//total number of rows obtained$highestColumn = $sheet->gethighestcolumn ();//total number of columns obtained for($i =1; $i < $highestRow +1; $i + +) {$data [$i] ['a'] = $objPHPExcel->getactivesheet ()->getcell ('A'. $i)GetValue (); $data [$i] ['b'] = $objPHPExcel->getactivesheet ()->getcell ('B'. $i)GetValue (); $data [$i] ['C'] = $objPHPExcel->getactivesheet ()->getcell ('C'. $i)GetValue (); $data [$i] ['D'] = $objPHPExcel->getactivesheet ()->getcell ('D'. $i)GetValue (); $data [$i] ['e'] = $objPHPExcel->getactivesheet ()->getcell ('E'. $i)GetValue (); $data [$i] ['F'] = $objPHPExcel->getactivesheet ()->getcell ('F'. $i)GetValue (); $data [$i] ['g'] = $objPHPExcel->getactivesheet ()->getcell ('G'. $i)GetValue (); //Formatting Data if(Is_object ($data [$i] ['a']) $data [$i] ['a']= $data [$i] ['a']->__tostring (); if(Is_object ($data [$i] ['b']) $data [$i] ['b']= $data [$i] ['b']->__tostring (); if(Is_object ($data [$i] ['C']) $data [$i] ['C']= $data [$i] ['C']->__tostring (); if(Is_object ($data [$i] ['D']) $data [$i] ['D']= $data [$i] ['D']->__tostring (); if(Is_object ($data [$i] ['e']) $data [$i] ['e']= $data [$i] ['e']->__tostring (); if(Is_object ($data [$i] ['F']) $data [$i] ['F']= $data [$i] ['F']->__tostring (); if(Is_object ($data [$i] ['g']) $data [$i] ['g']= $data [$i] ['g']->__tostring (); } return$data; }
Phpexcel string transcoding