php读取excel文件的简单实例_php教程-查字典教程网
php读取excel文件的简单实例
php读取excel文件的简单实例
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:$this->loadexcel();//半酣phpexcel文件$_ReadExcel=newPHPExcel_Read...

复制代码 代码如下:

$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教程学习
    编程开发子分类