pc_base::load_sys_class ( 'PHPExcel' , '' , 0 ); $filename = $_FILES['fileElem']['tmp_name']; $objPHPExcel = PHPExcel_IOFactory::load($filename);//加载文件 $i=0; $j=0; $count=4;//代表你需要多少列 $arr=[]; foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { //遍历工作表 foreach ($worksheet->getRowIterator() as $row) { //遍历行 $cellIterator = $row->getCellIterator(); //得到所有列 $cellIterator->setIterateOnlyExistingCells( false); // Loop all cells, even if it is not set foreach ($cellIterator as $cell) { //遍历列 if (!is_null($cell)) { //如果列不给空就得到它的坐标和计算的值 if($j>=$count){ $j=0; } $val=$cell->getCalculatedValue(); if($i>0&&!empty($val)){ $arr[$j][$i-1]=$val;//$i-1 代表第一行属于标题 } ++$j; } } ++$i; } } echo '<pre>'; print_r($arr);