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,并包含進來
相關文章
修改yii2.0用戶登錄使用的user表為其它的表實現方法(推薦)
下面小編就為大家?guī)硪黄薷膟ii2.0用戶登錄使用的user表為其它的表實現方法(推薦)。小編覺得挺不錯的,現在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-08-08
詳解thinkphp實現excel數據的導入導出(附完整案例)
本篇文章主要介紹了thinkphp實現excel數據的導入導出,具有一定的參考價值,感興趣的小伙伴們可以參考一下。2016-12-12

