后台生成EXCEL文档,自定义列
//response输出流处理
//设置编码、类型、文件名
getResponse().reset();
getResponse().setCharacterEncoding("utf-8");
getResponse().setContentType("application/vnd.ms-excel");
String useragent = getRequest().getHeader("user-agent");
String disposition = DownloadFilenameUtil.fileDisposition(useragent, "oralInput.xls");
getResponse().setHeader("Content-Disposition", disposition);
WritableWorkbook wwb = Workbook.createWorkbook( getResponse().getOutputStream() );
List fieldList = new ArrayList();
WritableSheet sheet1 = wwb.createSheet("已发送面试通知的人员", 0);
//头三行固定为 序号 工号 姓名
int i=0;
int j=0;
//序号批注设置为信息类guid 后续导入时使用该批注确定修改的信息类类型
sheet1.addCell(new Label(i++,j,"序号"));
fieldList.add("xh");
sheet1.addCell(generateTheadLabel(i++,j,"*体检序号"));
fieldList.add("tjxh");
sheet1.addCell(generateTheadLabel(i++,j,"招聘年度"));
fieldList.add("zpnd");
sheet1.addCell(generateTheadLabel(i++,j,"批次名称"));
fieldList.add("pcmc");
sheet1.addCell(generateTheadLabel(i++,j,"姓名"));
fieldList.add("xm");
sheet1.addCell(generateTheadLabel(i++,j,"应聘部门"));
fieldList.add("ypbm");
sheet1.addCell(generateTheadLabel(i++,j,"编制类别"));
fieldList.add("bzlb");
sheet1.addCell(generateTheadLabel(i++,j,"应聘岗位"));
fieldList.add("ypgw");
sheet1.addCell(generateTheadLabel(i++,j,"体检时间"));
fieldList.add("tjsj");
sheet1.addCell(generateTheadLabel(i++,j,"*体检结果"));
fieldList.add("tjcj");
sheet1.addCell(generateTheadLabel(i++,j,"备注"));
fieldList.add("bz");
j++;
for (PostApply user : pageList) {
i=0;
sheet1.addCell(new Label(i++,j,j+""));//序号
sheet1.addCell(new Label(i++,j,user.getPhyeNo()));//体检序号
sheet1.addCell(new Label(i++,j,user.getPostRelease().getRecruitYear()));//招聘年度
sheet1.addCell(new Label(i++,j,user.getPostRelease().getBatch()));//批次名称
sheet1.addCell(new Label(i++,j,user.getResume().getFullName()));//姓名
sheet1.addCell(new Label(i++,j,user.getPost().getPlan().getDeptValue()));//应聘部门
sheet1.addCell(new Label(i++,j,user.getPost().getPlan().getTypeValue()));//编制类别
sheet1.addCell(new Label(i++,j,user.getPost().getPostNameValue()));//应聘岗位
if (user.getPhyeTime() == null) {
sheet1.addCell(new Label(i++,j,""));//体检时间
} else {
sheet1.addCell(new Label(i++,j,TimeUtil.getDataTime(user.getPhyeTime().getTime(), "yyyy-MM-dd HH:mm")));//体检时间
}
sheet1.addCell(new Label(i++,j,CodeUtil.getItemValue(ICodeConstants.DM_XB_TJJG, user.getPhyeResult())));//体检结果
sheet1.addCell(new Label(i++,j,user.getPhyeRemark()));//备注
j++;
}
i=0;
for (String field : fieldList) {
WritableCellFeatures wcf = new WritableCellFeatures();
wcf.setComment(field);
sheet1.getWritableCell(i++, 0).setCellFeatures(wcf);
}
wwb.write();
wwb.close();