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表为其它的表实现方法(推荐)
下面小编就为大家带来一篇修改yii2.0用户登录使用的user表为其它的表实现方法(推荐)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧2017-08-08详解thinkphp实现excel数据的导入导出(附完整案例)
本篇文章主要介绍了thinkphp实现excel数据的导入导出,具有一定的参考价值,感兴趣的小伙伴们可以参考一下。2016-12-12
最新评论