php实例

关注公众号 jb51net

关闭
首页 > 网络编程 > PHP编程 > php实例 > php读取excel文件

php读取excel文件的简单实例

作者:

这篇文章介绍了php读取excel文件的简单实例,有需要的朋友可以参考一下

复制代码 代码如下:

     $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,并包含进来

您可能感兴趣的文章:
阅读全文