/** * @Title:exportInfo * @Descriptiom:人员信息表格导出 * @Date:2017年9月29日 * @param: * @return:void */ @SuppressWarnings("deprecation") public void exportInfo(){ try { if(StringUtils.isNotBlank(keyWord)){ keyWord=URLDecoder.decode(keyWord,"utf-8"); this.getModel().setName(keyWord); this.getModel().setName(URLDecoder.decode(this.getModel().getPresentJob(),"utf-8")); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } this.getModel().setSourceSubTeam(sourceSubTeamCode); List<TeamPersonnel> list = iservice.getInfos(this.getSID(),beginDate, endDate, this.getModel()); Map<String, String> sexcodeMap = new HashMap<String, String>();// 性别 Map<String, String> posttypeMap = new HashMap<String, String>();// 岗位类别 Map<String, String> depttypeMap = new HashMap<String, String>();// 所在单位分类 Map<String, String> majorMap = new HashMap<String, String>();// 专业细类 Map<String, String> organMap = new HashMap<String, String>();// 编制 Map<String, String> theTitleMap = new HashMap<String, String>();// 技术职称 Map<String, String> politMap = new HashMap<String, String>();// 政治面貌 Map<String, String> eduMap = new HashMap<String, String>();// 学历 // 性别 sexcodeMap = new HashMap<String, String>(); Cnds cndssexcode = Cnds.me(BasSex.class); List<BasSex> listsexcode = iservice.getList(cndssexcode); for (BasSex obj : listsexcode) { sexcodeMap.put(obj.getSexcode(),obj.getSexname()); } // 岗位类别 posttypeMap = new HashMap<String, String>(); Cnds cndsposttype = Cnds.me(ScheCodePost.class); List<ScheCodePost> listposttype = iservice.getList(cndsposttype); for (ScheCodePost obj : listposttype) { posttypeMap.put(obj.getPosttypecode(),obj.getPosttypename()); } // 所在单位分类 depttypeMap = new HashMap<String, String>(); Cnds cndsdepttype = Cnds.me(ScheCodeDepttype.class); List<ScheCodeDepttype> listdepttype = iservice.getList(cndsdepttype); for (ScheCodeDepttype obj : listdepttype) { depttypeMap.put(obj.getDepttypecode(),obj.getDepttypename()); } // 专业细类 majorMap = new HashMap<String, String>(); Cnds cndsmajor = Cnds.me(ScheCodeMajorsamtype.class); List<ScheCodeMajorsamtype> listmajor = iservice.getList(cndsmajor); for (ScheCodeMajorsamtype obj : listmajor) { majorMap.put(obj.getMajorsamtypecode(),obj.getMajorsamtypename()); } // 编制 organMap = new HashMap<String, String>(); organMap.put("1", "正式"); organMap.put("2", "聘用或劳务派遣"); organMap.put("3", "其他"); // 技术职称 theTitleMap = new HashMap<String, String>(); theTitleMap.put("1", "无"); theTitleMap.put("2", "初级"); theTitleMap.put("3", "中级"); theTitleMap.put("4", "高级"); // 政治面貌 politMap = new HashMap<String, String>(); Cnds cndspolit = Cnds.me(ScheCodePolistatus.class); List<ScheCodePolistatus> listpolit = iservice.getList(cndspolit); for (ScheCodePolistatus obj : listpolit) { politMap.put(obj.getPolistatuscode(),obj.getPolistatusname()); } // 学历 eduMap = new HashMap<String, String>(); eduMap.put("1", "研究生及以上"); eduMap.put("2", "本科"); eduMap.put("3", "大专"); eduMap.put("4", "中专、高中"); eduMap.put("5", "初中及以下"); HttpSession httpSession = ActionUtil.getRequest().getSession(); String teamTypeCode = (String) httpSession.getAttribute("teamOrgCode"); try { HttpServletRequest request = getRequest(); HttpServletResponse response = getResponse(); String path = request.getRealPath("/export/word/teamPersonnel.xls"); if("100".equals(teamTypeCode)){ path = request.getRealPath("/export/word/teamPersonnelKs.xls"); } InputStream in = new FileInputStream(new File(path)); HSSFWorkbook wb = new HSSFWorkbook(in); HSSFSheet sheet = wb.getSheetAt(0); /*设置边框以及垂直居中——单元格样式*/ HSSFCellStyle cellStyle = wb.createCellStyle(); cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); SimpleDateFormat sdff = new SimpleDateFormat("yyyy-MM-dd"); int r = 3; int i = 0; int xh = 1; if(list.size()>0){ for(TeamPersonnel ob:list){ r = r + 1; // sheet.shiftRows(r, sheet.getLastRowNum(), 1); HSSFRow row = sheet.createRow(r); row.setHeightInPoints(18); row.createCell(0).setCellValue(xh); row.createCell(1).setCellValue(ob.getName()==null?"":ob.getName()); row.createCell(2).setCellValue(ob.getIdno()==null?"":ob.getIdno()); row.createCell(3).setCellValue(ob.getSexcode()==null?"":sexcodeMap.get(ob.getSexcode())); row.createCell(4).setCellValue(ob.getDeptname()==null?"":ob.getDeptname()); row.createCell(5).setCellValue(ob.getPresentJob()==null?"":ob.getPresentJob()); row.createCell(6).setCellValue(ob.getPosttypecode()==null?"":posttypeMap.get(ob.getPosttypecode())); row.createCell(7).setCellValue(ob.getDepttypecode()==null?"":depttypeMap.get(ob.getDepttypecode())); if("100".equals(teamTypeCode)){ row.createCell(8).setCellValue(ob.getMajorsamtypecode()==null?"":majorMap.get(ob.getMajorsamtypecode())); i = 1; } row.createCell(8+i).setCellValue(ob.getOrgan()==null?"":organMap.get(ob.getOrgan())); row.createCell(9+i).setCellValue(ob.getBirthDay()==null?"":sdff.format(ob.getBirthDay())); row.createCell(10+i).setCellValue(ob.getWorkJoinDate()==null?"":ob.getWorkJoinDate()); row.createCell(11+i).setCellValue(ob.getPresentpostdate()==null?"":ob.getPresentpostdate()); row.createCell(12+i).setCellValue(ob.getPoliticalStatus()==null?"":politMap.get(ob.getPoliticalStatus())); row.createCell(13+i).setCellValue(ob.getFiredu()==null?"":eduMap.get(ob.getFiredu())); row.createCell(14+i).setCellValue(ob.getFiredumajor()==null?"":ob.getFiredumajor()); row.createCell(15+i).setCellValue(ob.getHighedu()==null?"":eduMap.get(ob.getHighedu())); row.createCell(16+i).setCellValue(ob.getHighedumajor()==null?"":ob.getHighedumajor()); row.createCell(17+i).setCellValue(ob.getTheTitle()==null?"":theTitleMap.get(ob.getTheTitle())); row.createCell(18+i).setCellValue(ob.getJointeamdate()==null?"":ob.getJointeamdate()); row.createCell(19+i).setCellValue(ob.getResJoinDate()==null?"":ob.getResJoinDate() ); row.createCell(20+i).setCellValue(ob.getNationTrainTimes()==null?"":ob.getNationTrainTimes().toString()); row.createCell(21+i).setCellValue(ob.getProvTrainTimes()==null?"":ob.getProvTrainTimes().toString()); row.createCell(22+i).setCellValue(ob.getGroupTrainTimes()==null?"":ob.getGroupTrainTimes().toString()); row.createCell(23+i).setCellValue(ob.getOtherTrainTimes()==null?"":ob.getOtherTrainTimes().toString()); row.createCell(24+i).setCellValue(ob.getExesuperaccinum()==null?"":ob.getExesuperaccinum().toString()); row.createCell(25+i).setCellValue(ob.getExemoreaccinum()==null?"":ob.getExemoreaccinum().toString()); row.createCell(26+i).setCellValue(ob.getNationcommnum()==null?"":ob.getNationcommnum().toString()); row.createCell(27+i).setCellValue(ob.getNationcommdate()==null?"":ob.getNationcommdate()); row.createCell(28+i).setCellValue(ob.getProcommnum()==null?"":ob.getProcommnum().toString()); row.createCell(29+i).setCellValue(ob.getProcommdate()==null?"":ob.getProcommdate()); row.createCell(30+i).setCellValue(ob.getCitycommnum()==null?"":ob.getCitycommnum().toString()); row.createCell(31+i).setCellValue(ob.getCitycommdate()==null?"":ob.getCitycommdate()); row.createCell(32+i).setCellValue(ob.getOthcommnum()==null?"":ob.getOthcommnum().toString()); row.createCell(33+i).setCellValue(ob.getOthcommdate()==null?"":ob.getOthcommdate()); row.createCell(34+i).setCellValue(ob.getIsgetqualify()==null?"":("1".equals(ob.getIsgetqualify())?"是":"否")); row.createCell(35+i).setCellValue(ob.getGetqualifydate()==null?"":ob.getGetqualifydate()); for(int j = 0;j<=35+i;j++){ row.getCell(j).setCellStyle(cellStyle); } xh++; } } String fileName = "人员信息表.xls"; //设为"UTF-8"IE乱码,谷歌正常,设为"gb2312"IE、谷歌均正常 fileName = new String(fileName.getBytes("gb2312"), "ISO-8859-1"); response.setCharacterEncoding("UTF-8"); response.setHeader("content-disposition", "attachment;filename=\"" + fileName + "\""); //new String(filename.getBytes("GBK"),"ISO8859-1") response.setContentType("application/octet-stream"); OutputStream out = response.getOutputStream(); wb.write(out); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
人员信息表格导出方法类
猜你喜欢
转载自www.cnblogs.com/ComputerVip/p/12764969.html
今日推荐
周排行