手机
当前位置:查字典教程网 >编程开发 >php教程 >php读取excel文件的简单实例
php读取excel文件的简单实例
摘要:复制代码代码如下:$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读取excel文件的简单实例】相关文章:

文件上传的实现

PHP获取文件行数的方法

多文件上传的例子

PHP文件读取功能的应用实例

php简单smarty入门程序实例

php注入实例

php自定义hash函数实例

php环境上传大文件需要注意的事项

php实现TCP端口检测的方法

php中文件上传的安全问题

精品推荐
分类导航