//载入PHPExcel类include(dirname(__FILE__).'/phpexcel/PHPExcel.php'); $Obj = new PHPExcel_Reader_Excel5(); $Obj->setReadDataOnly(true); //读取demo.xls文件 $phpExcel = $Obj->load(dirname(__FILE__).'/output.xls'); //获取当前活动sheet $objWorksheet = $phpExcel->getActiveSheet(); //获取行数 $highestRow = $objWorksheet->getHighestRow(); //获取列数 //by bbs.it-home.org $highestColumn = $objWorksheet->getHighestColumn(); $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); //循环输出数据 $data = array(); for($row = 1; $row <= $highestRow; $row) { for($col = 0; $col < $highestColumnIndex; $col) { $val = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue(); $data[$row][$col] = trim($val); } } echo ''; print_r($data); echo ''; 复制代码