ITPub博客

首页 > 应用开发 > IT综合 > PHPExcel读取EXCEL文件

PHPExcel读取EXCEL文件

原创 IT综合 作者:jyb2014 时间:2014-11-10 14:27:50 0 删除 编辑
$fileName = 'excel.xls';
$path = 'path';
$filePath = $path.$fileName;
$PHPExcel = new PHPExcel();  
$PHPReader = new PHPExcel_Reader_Excel2007();    
if(!$PHPReader->canRead($filePath)){      
 $PHPReader = new PHPExcel_Reader_Excel5(); 
 if(!$PHPReader->canRead($filePath)){      
  echo 'no Excel';
  return ;
 }
}
$PHPExcel = $PHPReader->load($filePath);
$currentSheet = $PHPExcel->getSheet(0);
/**取得一共有多少列*/
$allColumn = $currentSheet->getHighestColumn();   
/**取得一共有多少行*/
$allRow = array($currentSheet->getHighestRow()); 
for($currentRow = 1;$currentRow<=$allRow;$currentRow++){
 for($currentColumn='A';$currentColumn<=$allColumn;$currentColumn++){
  $address = $currentColumn.$currentRow;
  
  echo $currentSheet->getCell($address)->getValue()."\t";
 }
 echo "\n";
}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29753604/viewspace-1327213/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-07-15

  • 博文量
    101
  • 访问量
    196518