| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
13年前发布

使用PHPExcel读取xls/xlsx文件

require_once( LIB.'Excel/excel/PHPExcel/IOFactory.php');    function readexcel( $filePath) {  $PHPReader = new PHPExcel_Reader_Excel5();           if(!$PHPReader->canRead($filePath)){                  $PHPReader = new PHPExcel_Reader_Excel5();                        if(!$PHPReader->canRead($filePath)){                                   echo 'no Excel';                             return ;                        }              }    $PHPExcel = $PHPReader->load($filePath);      $currentSheet = $PHPExcel->getSheet(0);  /**取得一共有多少列*/    $allColumn = $currentSheet->getHighestColumn();     /**取得一共有多少行*/      $allRow = $currentSheet->getHighestRow();    $all = array();  for( $currentRow = 1 ; $currentRow <= $allRow ; $currentRow++){              $flag = 0;            $col = array();            for($currentColumn='A'; getascii($currentColumn) <= getascii($allColumn) ; $currentColumn++){                                 $address = $currentColumn.$currentRow;                       $string = $currentSheet->getCell($address)->getValue();                                    $col[$flag] = $string;                    $flag++;            }        $all[] = $col;  }  return $all;  }

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1374292115525.html
PHPExcel PHP开发