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; }

 

相关文章:

  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2021-09-16
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-28
  • 2022-12-23
  • 2021-05-19
  • 2022-01-06
  • 2022-02-26
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案