//引入类
use PhpOffice\PhpSpreadsheet\IOFactory;
/**
* Excel导入
* @param $inputfile string EXCEL路径 ./upload/supplement_order/xlsx_ledge/5025-补单导入模板0721.xlsx
* @return array
*/
function getExcelData($inputfile)
{
//根据类型创建合适的读取器对象 这里写死了
$objread = IOFactory::createreader('Xlsx');
// ./upload/supplement_order/xlsx_ledge/5025-补单导入模板0721.xlsx
$objspreadsheet = $objread->load($inputfile);
$objworksheet = $objspreadsheet->getsheet(0);
$data = $objworksheet->toarray();
return $data;
}
参考文档
https://blog.csdn.net/u011584949/article/details/103472464