使用phpExcel读取excel文件
include_once '../include/common.inc.php'; include_once MC_ROOT.'include/smarty.inc.php'; date_default_timezone_set('Asia/ShangHai'); require_once CMS_ROOT . '/lib/PHPExcel.php'; $filename = 'C:\Users\15889\Desktop\ccc.xlsx';//要读取的excel文件 $reader = PHPExcel_IOFactory::createReader('Excel2007'); //设置以Excel5格式(Excel97-2003工作簿) $PHPExcel = $reader->load($filename); // 载入excel文件 $sheet = $PHPExcel->getSheet(0); // 读取第一個工作表 $highestRow = $sheet->getHighestRow(); // 取得总行数 $highestColumm = $sheet->getHighestColumn(); // 取得总列数 /** 循环读取每个单元格的数据 */ $data=array(); for ($column = 'A'; $column <= $highestColumm; $column++) { for ($row = 1; $row <= $highestRow; $row++) { $data[] = $sheet->getCell($column.$row)->getValue(); } } var_dump($data);