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; }
  • 相关阅读:
    bzoj3211 花神游历各国
    bzoj1010
    day8
    day6&7
    bzoj1087
    noi同步赛day1
    bzoj1076
    day3&4&5
    bzoj1079 dp
    cholesky分解
  • 原文地址:https://www.cnblogs.com/yyh1/p/6281821.html
Copyright © 2011-2022 走看看