thinkphp中使用phpexcel读取所有的行记录
ThinkPHP3.2使用phpexcle
将phpexcel放到Think\Org\PHPExcel中
public function index() { import('Org.PHPExcel.PHPExcel'); $reader = \PHPExcel_IOFactory::createReader('Excel5'); $filePath="./a.xls"; $objPHPExcel = $reader->load($filePath); // 载入excel文件 $sheet = $objPHPExcel->getSheet(0); // 读取第一個工作表 foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { //遍历工作表 //echo 'Worksheet - ' , $worksheet->getTitle() , PHP_EOL; foreach ($worksheet->getRowIterator() as $key=>$row) { //遍历行 // echo $row->getRowIndex()."<br/>"; $cellIterator = $row->getCellIterator(); //得到所有列 $cellIterator->setIterateOnlyExistingCells( false); // Loop all cells, even if it is not set foreach ($cellIterator as $cell) { //遍历列 if (!is_null($cell)) { //如果列不给空就得到它的坐标和计算的值 $rows[$key][]= $cell->getCalculatedValue(); } } } } dump($rows);exit; }