Phpexcel string transcoding

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.