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