This article mainly introduces the method of PHP to get Excel file data. Has a good reference value. Let's take a look at the little series.
Very simple can be achieved, the following for everyone to briefly introduce the next
1, download Phpexcel class, is a folder, there must be a file phpexcel.php, two in the sibling directory
Require __dir__. './phpexcel/iofactory.php '; $PHPReader = new \phpexcel_reader_excel2007 (); Determine the file type if (! $PHPReader->canread ($filePath)) { $PHPReader = new \phpexcel_reader_excel5 (); if (! $PHPReader->canread ($filePath)) { echo ' no Excel '; return false; } } $PHPExcel = $PHPReader->load ($filePath); /** read the first worksheet in an Excel file * /$currentSheet = $PHPExcel->getsheet (0); /** gets the largest column number * /$allColumn = $currentSheet->gethighestcolumn (); /** get total number of lines * /$allRow = $currentSheet->gethighestrow (); /** output from line 1th * /for ($currentRow = 1; $currentRow <= $allRow; $currentRow + +) { /** start output from column A * /for ($ Currentcolumn = ' A '; $currentColumn <= $allColumn; $currentColumn + +) { $val = $currentSheet->getcellbycolumnandrow (ord ($currentColumn)-+, $currentRow) GetValue (); /**ord () Converts the character to a decimal number */ $date [$currentRow -1][] = $val; } } return $date;
The above is the whole content of this article, I hope that everyone's study has helped.