<?php set_time_limit(0); $dir = dirname(__FILE__);//当前脚本所在路径 require $dir."/PHPExcel_1.8.0/Classes/PHPExcel.php"; //$objPHPExcel = new PHPExcel();//实例化PHPExcel类 $filename = $dir."/20151016091328_95039.xls"; $objPHPExcel=PHPExcel_IOFactory::load($filename);//加载文件 // $sheetCount = $objPHPExcel->getSheetCount();//获取excel文件里有多少个sheet // for($i=0;$i<$sheetCount;$i++){ // $data = $objPHPExcel->getSheet($i)->toArray();//读取每个sheet 全部放入数组中 // print_r($data); // } foreach ($objPHPExcel->getWorksheetIterator() as $sheet) {//循环取sheet foreach($sheet->getRowIterator() as $row){//逐行处理 if($row->getRowIndex()<2){ continue; } foreach ($row->getCellIterator() as $cell) {//逐列读取 $data = $cell->getValue();//获取单元格数据 echo $data." "; } echo '<br>'; } echo '<br>'; }