Reading the contents of an Excel file with the Phpexcel class

Source: Internet
Author: User

Here to the Phpexcel class do not introduce, interested friends can consult their own information

There is a phpexcel.php file under the Classes folder, which is the main entry file for this class library, which is introduced before use.

Other classes, which are automatically loaded in this class

1         //set up reader objects to read 2007 and 2003 versions of Excel files with two different class objects respectively2         $PHPReader=Newphpexcel_reader_excel2007 ();3         if( !$PHPReader->canread ($filePath))4         {5             $PHPReader=NewPhpexcel_reader_excel5 ();6             if( !$PHPReader->canread ($filePath)){7                 Echo' No Excel ';8                 return ;9             }Ten         } One  A         $PHPExcel=$PHPReader->load ($filePath); Read File -         $currentSheet=$PHPExcel->getsheet (0);//Read the first workbook -         $allColumn=$currentSheet->gethighestcolumn ();//of all Columns the         $allRow=$currentSheet->gethighestrow ();//All line Numbers -        -         $data=Array();///The following is the reading of the contents of the column you want to get -          for($rowIndex= 2;$rowIndex<=$allRow;$rowIndex++) +         { -             $data[] =Array( +' id ' =$cell=$currentSheet->getcell (' A '.$rowIndex)->getvalue (), A' Score ' =$cell=$currentSheet->getcell (' H '.$rowIndex)->getvalue (), at' Ranking ' =$cell=$currentSheet->getcell (' I ').$rowIndex)->getvalue (), -             ); -}

Reading the contents of an Excel file with the Phpexcel class

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.