用文件流的的方式来解决
try {
$objReader = \PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load("2018.xlsx");
$objWorksheet = $objPHPExcel->getActiveSheet();
$data = [];
foreach ($objWorksheet->getRowIterator() as $row) {
$temp = [];
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false);
foreach ($cellIterator as $cell) {
$temp[] = $cell->getValue();
}
array_push($data, $temp);
}
var_dump($data);
}catch (\Exception $e){
echo $e->getMessage();
}