@RequestMapping("/sms/salary/exportSalaryAnalyse.do")//前台请求的方法
public void exportSalaryAnalyse(HttpServletRequest req, HttpServletResponse response)throws Exception {
List<map<String,Object>> list = salaryService.exportWage();//根据条件查询出符合条件的信息装入容器
Map<String, List<Map<String, Object>>> excelMap = new HashMap<String, List<Map<String, Object>>>();
// sheet
List<Map<String, Object>> sheetList = new ArrayList<Map<String, Object>>();
// row 行数
for (int j = 0; j < list.size(); j++) {
sheetList.add(hashMap);
}
excelMap.put("收入分析", sheetList);
// 正常表头 注意列字不能少
LinkedHashMap<String, String> head = new LinkedHashMap<String, String>();
head.put("列" + 0, "序号");
head.put("列" + 1, "人员代码");
head.put("列" + 2, "人员姓名");
head.put("列" + 3, "机构名称");
head.put("列" + 4, "计算月份");
// 设置每个sheet页的表头
List<LinkedHashMap<String, String>> sheetHead = new ArrayList<LinkedHashMap<String, String>>();
sheetHead.add(head);
// 设置多sheet页
Map<String, List<LinkedHashMap<String, String>>> map = new HashMap<String, List<LinkedHashMap<String, String>>>();
map.put("收入分析", sheetHead); //对应上面excelMap put的招募情况报表
ExcelWrite write = new ExcelWrite();
//设置response 这样就可以前台弹出框进行下载了
response.setContentType("application/msexcel");
response.setHeader("Content-disposition", "attachment; filename="
+ DateHelper.getSysStr("yyyyMMddHHmmss") + "export.xls");
write.setResponse(response);
write.setSheetHead(map);
write.setMergeCell(true);
//write.addNotLockArea("测试1", "A3:F8");
// 设置数据,key需要跟sheet页的key相同,值为需要写的数据
write.writeExcel(excelMap);
return null;
}
public void exportSalaryAnalyse(HttpServletRequest req, HttpServletResponse response)throws Exception {
List<map<String,Object>> list = salaryService.exportWage();//根据条件查询出符合条件的信息装入容器
Map<String, List<Map<String, Object>>> excelMap = new HashMap<String, List<Map<String, Object>>>();
// sheet
List<Map<String, Object>> sheetList = new ArrayList<Map<String, Object>>();
// row 行数
for (int j = 0; j < list.size(); j++) {
Map<String, Object> hashMap = new HashMap<String, Object>();
map<String,Object> vo = list.get(j);
hashMap.put("列" + 0, ActionHelper.toStr(j + 1)); //序号
hashMap.put("列" + 2, vo.getkey("B"));
hashMap.put("列" + 3, vo.getkey("C"));
hashMap.put("列" + 4, vo.getkey("D"));
sheetList.add(hashMap);
}
excelMap.put("收入分析", sheetList);
// 正常表头 注意列字不能少
LinkedHashMap<String, String> head = new LinkedHashMap<String, String>();
head.put("列" + 0, "序号");
head.put("列" + 1, "人员代码");
head.put("列" + 2, "人员姓名");
head.put("列" + 3, "机构名称");
head.put("列" + 4, "计算月份");
// 设置每个sheet页的表头
List<LinkedHashMap<String, String>> sheetHead = new ArrayList<LinkedHashMap<String, String>>();
sheetHead.add(head);
// 设置多sheet页
Map<String, List<LinkedHashMap<String, String>>> map = new HashMap<String, List<LinkedHashMap<String, String>>>();
map.put("收入分析", sheetHead); //对应上面excelMap put的招募情况报表
ExcelWrite write = new ExcelWrite();
//设置response 这样就可以前台弹出框进行下载了
response.setContentType("application/msexcel");
response.setHeader("Content-disposition", "attachment; filename="
+ DateHelper.getSysStr("yyyyMMddHHmmss") + "export.xls");
write.setResponse(response);
write.setSheetHead(map);
write.setMergeCell(true);
//write.addNotLockArea("测试1", "A3:F8");
// 设置数据,key需要跟sheet页的key相同,值为需要写的数据
write.writeExcel(excelMap);
return null;
}