zoukankan      html  css  js  c++  java
  • php解析excel文件

    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; }
  • 相关阅读:
    HDU-统计难题
    POJ-A Simple Problem with Integers
    HDU-I Hate It
    个人站立会议06
    个人站立会议05
    个人站立会议04
    易校小程序典型用户需求分析
    个人站立会议03
    个人第二次晚间站立总结会议
    个人站立会议02
  • 原文地址:https://www.cnblogs.com/yyh1/p/6281821.html
Copyright © 2011-2022 走看看