composer require phpoffice/phpexcel : "*"
$fileType = \PHPExcel_IOFactory::identify($file);
$excelReader = \PHPExcel_IOFactory::createReader($fileType);
$phpExcel = $excelReader->load($file)->getSheet(0);
$total_line = $phpExcel->getHighestRow();//总行数
$total_column = $phpExcel->getHighestColumn();//总列数
$data = [];
if($total_line > 1) {
for ($row = 1; $row <= $total_line; $row++) {
for ($column = 'A'; $column <= $total_column; $column++) {
$data[$row][] = trim($phpExcel->getCell($column . $row)->getValue());
}
}
}
参考:https://blog.csdn.net/renamayu/article/details/53431701