欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-04-10 19:51:26
...
复制代码 代码如下:

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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/328155.htmlTechArticle复制代码 代码如下: $this-loadexcel();//半酣phpexcel文件 $_ReadExcel = new PHPExcel_Reader_Excel2007(); if(!$_ReadExcel-canRead('link.xls')){ $_ReadExcel = new PHPExcel_...