public static function getStaffByXlsx($path) {
/*dirname(__file__): 当前代码所在的目录,$path: ”/文件名“ */
$PHPReader = PHPExcel_IOFactory::createReaderForFile(dirname(__file__) . $path);
/*加载当前目录下边的文件*/
$PHPExcel = $PHPReader->load(dirname(__file__) . $path);
/*获取表的第一个sheet*/
$currentSheet = $PHPExcel->getSheet(0);
/*获取表里内容的最大列数*/
$allColumn = $currentSheet->getHighestColumn();
/*获取表里内容的最大行数*/
$allRow = $currentSheet->getHighestRow();
$data = array();
for ($currentRow = 3; $currentRow <= $allRow; $currentRow++) {
for($currentColumn= 'A'; $currentColumn<= $allColumn; $currentColumn++){
$address = $currentColumn.$currentRow;
$val = $currentSheet->getCell($address)->getValue();
$data[$currentRow - 3][$currentColumn] = $val;
}
}
if (empty($data)) {
return ['error' => 1, 'message' => 'data is empty'];
}
return $data;
}