首頁 >後端開發 >php教程 >php读取excel文件的简单实例_PHP

php读取excel文件的简单实例_PHP

WBOY
WBOY原創
2016-06-01 12:03:441753瀏覽

复制代码 代码如下:
     $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                $currentSheet = $_phpExcel->getSheet($s);
                $allColumn = $currentSheet->getHighestColumn();
                $allRow = $currentSheet->getHighestRow();
                for($r = 1;$r
                    for($currentColumn='A';$currentColumn                        $address = $currentColumn.$r;
                        $newExcel[] = $currentSheet->getCell($address)->getValue();
                    }
                }
            }

后面就是对数组的操作了--不过要先下载好phpexcel,并包含进来

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn