zoukankan      html  css  js  c++  java
  • 后台生成EXCEL文档,自定义列

    后台生成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<String> fieldList = new ArrayList<String>();
    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();

  • 相关阅读:
    mac下完全卸载程序的方法
    Mac下检测NSTableView的滑动事件的方法
    一行代码起动全屏
    Unsupported compiler '4.0' selected for architecture 'i386'类错误解决办法
    编译错误“The run destination My Mac 64bit is not valid for Running the scheme '***',解决办法
    ios项目中导入百度地图SDK出错的问题
    Unable to resolve target 'android9'解决办法
    ios保存录制好的视频到相簿的方法
    NSTableView系列之代码创建(不用nib)
    谈内链优化不是每个站点都能做的
  • 原文地址:https://www.cnblogs.com/jiangbotao233/p/7449977.html
Copyright © 2011-2022 走看看