导入的时候,处理时间和日期格式的数据
使用PHPExcel_Shared_Date::ExcelToPHP($t) 可以处理Excel导出日期格式数据
set_time_limit(0);
ini_set("memory_limit", "1024M"); $objReader = PHPExcel_IOFactory::createReader('Excel2007'); $objExcel = $objReader->load($file_name); $sheet = $objExcel->getSheet(0); $rows = $sheet->getHighestRow(); $cols = $sheet->getHighestColumn(); for($i=3;$i<=$rows;$i++){ $str = ''; for($j='A';$j!='AQ';$j++){ $str .=(string)$objExcel->getActiveSheet()->getCell("$j$i")->getValue().'\'; } $import_arr = explode('\', $str); $import_arr = array_merge(array(0),$import_arr); $t_date = gmdate("Y-m-d H:i:s", PHPExcel_Shared_Date::ExcelToPHP($import_arr[2])); $t_time = gmdate("H:i:s", PHPExcel_Shared_Date::ExcelToPHP($import_arr[3])); $data = array(); $data['visit_date'] = $t_date; $data['visit_time'] = $t_time; //... }