zoukankan      html  css  js  c++  java
  • php读取excel文件的实例代码

    php读取excel文件的实例代码。

    代码: 

    <?php
    /**
    * php读取excel文件
    * by www.jbxue.com
    */
    $this->loadexcel();//半酣phpexcel文件
    $_ReadExcel = new PHPExcel_Reader_Excel2007();
    if(!$_ReadExcel->canRead('link.xls')){
    $_ReadExcel = new PHPExcel_Reader_Excel5();
     }
    $_phpExcel = $_ReadExcel->load('link.xls');
    $sheetCount = $_phpExcel->getSheetCount();
    $newExcel = array();
    $excelData = array();
    for($s = 0;$s<$sheetCount;$s++) {
     $currentSheet = $_phpExcel->getSheet($s);
    $allColumn = $currentSheet->getHighestColumn();
      $allRow = $currentSheet->getHighestRow();
      for($r = 1;$r<=$allRow;$r++){
    for($currentColumn='A';$currentColumn<=$allColumn;$currentColumn++){
      $address = $currentColumn.$r;
      $newExcel[] = $currentSheet->getCell($address)->getValue();
      }
     }
     }
    后面就是对数组的操作了--不过要先下载好phpexcel,并包含进来。
  • 相关阅读:
    课程设计第三次实验总结
    课程设计第二次实验总结
    2019春第一次课程设计实验报告
    第十二周作业
    第十一周作业
    第十周作业
    第九周作业
    第八周作业
    第七周作业
    第六周作业
  • 原文地址:https://www.cnblogs.com/linuxnotes/p/3284094.html
Copyright © 2011-2022 走看看