exle 表的数据获取
<?php header("Content-Type:text/html;charset=utf-8"); $dir=dirname(__FILE__);//找到当前脚本所在路径 require $dir."/PHPExcel/IOFactory.php";//引入读取excel的类文件 $filename=$dir."/export_1.xls"; $objPHPExcel=PHPExcel_IOFactory::load($filename);//加载文件 //1.0 // $sheetCount=$objPHPExcel->getSheetCount(); // for($i=0;$i<$sheetCount;$i++) // { // $data=$objPHPExcel->getSheet($i)->toArray(); // print_r($data); // } //2.0 // foreach ($objPHPExcel->getWorksheetIterator() as $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>"; }