PHP Get Excel file data

Source: Internet
Author: User
Tags ord

Very simple can be achieved, the following for everyone to briefly introduce the next

1, download Phpexcel class, is a folder, you have to have a file phpexcel. PHP, two in the sibling directory

1 require__dir__. './phpexcel/iofactory.php ';2 3         $PHPReader=New\phpexcel_reader_excel2007 ();4 5         //determine file type6         if(!$PHPReader->canread ($filePath)) {7             $PHPReader=New\phpexcel_reader_excel5 ();8 9             if(!$PHPReader->canread ($filePath)) {Ten                 Echo' No Excel '; One                 return false; A             } -         } -  the         $PHPExcel=$PHPReader->load ($filePath); -         /** Read the first worksheet in an Excel file*/ -  -         $currentSheet=$PHPExcel->getsheet (0); +         /** Get the maximum number of columns*/ -  +         $allColumn=$currentSheet-Gethighestcolumn (); A         /** Get a total number of lines*/ at  -         $allRow=$currentSheet-Gethighestrow (); -  -         /** Start output from line 1th*/ -          for($currentRow= 1;$currentRow<=$allRow;$currentRow++) { -  in             /** Start output from column a*/ -              for($currentColumn= ' A ';$currentColumn<=$allColumn;$currentColumn++) { to                 $val=$currentSheet->getcellbycolumnandrow (Ord($currentColumn)-65,$currentRow),GetValue (); +                 /**ord () converts a character to a decimal number*/ -                 $date[$currentRow-1][] =$val; the             } *  $         }Panax Notoginseng         return $date;

PHP Get Excel file data

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.