$file = '';//文件名称
$file_ext = explode('.',$file);
$file_ext = $file_ext[1];
$data['file_ext'] = $file_ext;
require '../application/helpers/PHPExcel.php';
//判断后缀
if($file_ext === 'xls'){
$objReader = new PHPExcel_Reader_Excel5();
}
if($file_ext === 'xlsx'){
$objReader = new PHPExcel_Reader_Excel2007();
}
$candfile_name = "./canddata/".$time."/".time()."/cand_picture/cands/".$file;
$data['cand_file'] = $candfile_name;
$objPHPExcel = $objReader->load($candfile_name); //指定的文件
$sheet = $objPHPExcel->getSheet(0); //指定的表
$highestRow = $sheet->getHighestRow(); // 取得总行数
$highestColumn = $sheet->getHighestColumn(); // 取得总列数
//从第2行开始读起
for( $i=2; $i <= $highestRow; $i++ ){
//显示各列
for( $j='A'; $j<='I'; $j++ ){
if($j=='I'){
$arr[$i][$j] = $sheet->getCell($j.$i)->getValue();
}else{
$arr[$i][$j] = replace_special_char($sheet->getCell($j.$i)->getValue());
}
}
}
foreach ( $arr as $key => $value ) {
$cands[$key]['bank_one'] = trim(replace_special_char($value['B']));
$cands[$key]['bank_two'] = trim(replace_special_char($value['C']));
$cands[$key]['cand_name'] = trim(replace_special_char($value['D']));
$cands[$key]['sex'] = trim(replace_special_char($value['E']));
$cands[$key]['cand_card'] = trim(replace_special_char($value['F']));
$cands[$key]['cand_iphone'] = trim(replace_special_char($value['G']));
$cands[$key]['logname'] = trim(replace_special_char($value['H']));
$cands[$key]['card'] = trim(replace_special_char($value['I']));
$cands[$key]['creat_time'] = date('Y-m-d H:i:s');
}