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

php技术php读取excel文件的简单实例,转载需保留来源!

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。