Controller::loadModel('middle'); //加载model
$sql = "select * from xes_zy_chuzhong where createtime<='" . $date2 ."' and createtime>='" . $date1 . "' order by id desc ";
$result = $this->middle->query($sql); //查处数据
$this->Xls->sendheader('chu'.date('YmdHis'));//设置excel名称
$num = count($result);
echo $this->Xls->xlsBOF(); // 输出第一行标题
echo $this->Xls->xlsWriteLabel(0, 0, iconv('UTF-8', 'GBK', "id"));
echo $this->Xls->xlsWriteLabel(0, 1, iconv('UTF-8', 'GBK//IGNORE', "申报时间"));
echo $this->Xls->xlsWriteLabel(0, 2, iconv('UTF-8', 'GBK', "姓名"));
echo $this->Xls->xlsWriteLabel(0, 3, iconv('UTF-8', 'GBK', "区"));
echo $this->Xls->xlsWriteLabel(0, 4, iconv('UTF-8', 'GBK', "学校"));
echo $this->Xls->xlsWriteLabel(0, 5, iconv('UTF-8', 'GBK', "就读年级"));
echo $this->Xls->xlsWriteLabel(0, 6, iconv('UTF-8', 'GBK', "统考"));
echo $this->Xls->xlsWriteLabel(0, 7, iconv('UTF-8', 'GBK', "英语年级排名"));
echo $this->Xls->xlsWriteLabel(0, 8, iconv('UTF-8', 'GBK', "英语班级排名"));
echo $this->Xls->xlsWriteLabel(0, 9, iconv('UTF-8', 'GBK', "英语卷面分值"));
echo $this->Xls->xlsWriteLabel(0, 10, iconv('UTF-8', 'GBK', "英语本人得分"));
echo $this->Xls->xlsWriteLabel(0, 11, iconv('UTF-8', 'GBK', "英语秋季班"));
echo $this->Xls->xlsWriteLabel(0, 12, iconv('UTF-8', 'GBK', "英语寒假班"));
echo $this->Xls->xlsWriteLabel(0, 13, iconv('UTF-8', 'GBK', "父母电话"));
echo $this->Xls->xlsWriteLabel(0, 14, iconv('UTF-8', 'GBK', "家庭电话"));
echo $this->Xls->xlsWriteLabel(0, 15, iconv('UTF-8', 'GBK', "其他科目秋季班"));
echo $this->Xls->xlsWriteLabel(0, 16, iconv('UTF-8', 'GBK', "其他科目寒假班"));
echo $this->Xls->xlsWriteLabel(0, 17, iconv('UTF-8', 'GBK', "大区"));
echo $this->Xls->xlsWriteLabel(0, 18, iconv('UTF-8', 'GBK', "服务中心地址"));
echo $this->Xls->xlsWriteLabel(0, 19, iconv('UTF-8', 'GBK', "身份"));
echo $this->Xls->xlsWriteLabel(0, 20, iconv('UTF-8', 'GBK', "数学年级排名"));
echo $this->Xls->xlsWriteLabel(0, 21, iconv('UTF-8', 'GBK', "数学班级排名"));
echo $this->Xls->xlsWriteLabel(0, 22, iconv('UTF-8', 'GBK', "数学卷面得分"));
echo $this->Xls->xlsWriteLabel(0, 23, iconv('UTF-8', 'GBK', "数学本人得分"));
echo $this->Xls->xlsWriteLabel(0, 24, iconv('UTF-8', 'GBK', "物理年级排名"));
echo $this->Xls->xlsWriteLabel(0, 25, iconv('UTF-8', 'GBK', "物理班级排名"));
echo $this->Xls->xlsWriteLabel(0, 26, iconv('UTF-8', 'GBK', "物理卷面得分"));
echo $this->Xls->xlsWriteLabel(0, 27, iconv('UTF-8', 'GBK', "物理本人得分"));
echo $this->Xls->xlsWriteLabel(0, 28, iconv('UTF-8', 'GBK', "化学年级排名"));
echo $this->Xls->xlsWriteLabel(0, 29, iconv('UTF-8', 'GBK', "化学班级排名"));
echo $this->Xls->xlsWriteLabel(0, 30, iconv('UTF-8', 'GBK', "化学本人得分"));
echo $this->Xls->xlsWriteLabel(0, 31, iconv('UTF-8', 'GBK', "全科总分年级排名"));
// 开始递归导出
$j = 1;
for ($i = 0; $i < $num; $i++) {
$arrArea = explode('&', $result[$i]['xes_zy_chuzhong']['server_center']);
echo $this->Xls->xlsWriteLabel($j, 0, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['id']));
echo $this->Xls->xlsWriteLabel($j, 1, iconv('UTF-8', 'GBK//IGNORE', $result[$i]['xes_zy_chuzhong']['createtime']));
echo $this->Xls->xlsWriteLabel($j, 2, iconv('UTF-8', 'GBK//IGNORE', $result[$i]['xes_zy_chuzhong']['username']));
echo $this->Xls->xlsWriteLabel($j, 3, iconv('UTF-8', 'GBK//IGNORE', $result[$i]['xes_zy_chuzhong']['area']));
echo $this->Xls->xlsWriteLabel($j, 4, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['school']));
echo $this->Xls->xlsWriteLabel($j, 5, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['usergrade']));
echo $this->Xls->xlsWriteLabel($j, 6, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['tongkao']));
echo $this->Xls->xlsWriteLabel($j, 7, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['englishranking']));
echo $this->Xls->xlsWriteLabel($j, 8, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['totalranking']));
echo $this->Xls->xlsWriteLabel($j, 9, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['yingmanfen']));
echo $this->Xls->xlsWriteLabel($j, 10, iconv('UTF-8', 'GBK',$result[$i]['xes_zy_chuzhong']['score']));
echo $this->Xls->xlsWriteLabel($j, 11, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['xes_class']));
echo $this->Xls->xlsWriteLabel($j, 12, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['xeh_class']));
echo $this->Xls->xlsWriteLabel($j, 13, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['motherphone']));
echo $this->Xls->xlsWriteLabel($j, 14, iconv('UTF-8', 'GBK', isset($result[$i]['xes_zy_chuzhong']['homephone'])?$result[$i]['xes_zy_chuzhong']['homephone']:'-'));
echo $this->Xls->xlsWriteLabel($j, 15, iconv('UTF-8', 'GBK//IGNORE', isset($result[$i]['xes_zy_chuzhong']['yes_class'])?$result[$i]['xes_zy_chuzhong']['yes_class']:'-'));
echo $this->Xls->xlsWriteLabel($j, 16, iconv('UTF-8', 'GBK//IGNORE', isset($result[$i]['xes_zy_chuzhong']['yeh_class'])?$result[$i]['xes_zy_chuzhong']['yeh_class']:'-'));
echo $this->Xls->xlsWriteLabel($j, 17, iconv('UTF-8', 'GBK', isset($arrArea[0])?$arrArea[0]:'-'));
echo $this->Xls->xlsWriteLabel($j, 18, iconv('UTF-8', 'GBK', isset($arrArea[1])?$arrArea[1]:'-'));
echo $this->Xls->xlsWriteLabel($j, 19, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['identity']));
echo $this->Xls->xlsWriteLabel($j, 20, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['math_grade']));
echo $this->Xls->xlsWriteLabel($j, 21, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['math_class']));
echo $this->Xls->xlsWriteLabel($j, 22, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['math_usescore']));
echo $this->Xls->xlsWriteLabel($j, 23, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['physics_grade']));
echo $this->Xls->xlsWriteLabel($j, 24, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['physics_class']));
echo $this->Xls->xlsWriteLabel($j, 25, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['physics_score']));
echo $this->Xls->xlsWriteLabel($j, 26, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['physics_usescore']));
echo $this->Xls->xlsWriteLabel($j, 27, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['physics_grade']));
echo $this->Xls->xlsWriteLabel($j, 28, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['chemistry_grade']));
echo $this->Xls->xlsWriteLabel($j, 29, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['chemistry_class']));
echo $this->Xls->xlsWriteLabel($j, 30, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['chemistry_usescore']));
echo $this->Xls->xlsWriteLabel($j, 31, iconv('UTF-8', 'GBK', $result[$i]['xes_zy_chuzhong']['sunscore']));
$j++;
}
echo $this->Xls->xlsEOF();
exit();