Excel模板来自定义的一个excel模板,相当于是用户查询数据,数据填充到一个模板的Excel里,再导出Excel
/*创建模板*/
String a=request.getSession().getServletContext().getRealPath("/resource/河南能源化工集团安全监控系统联网系统瓦斯涌出异常信息表.xlsx");
获取模板
TemplateExportParams params=new TemplateExportParams(a);
获取查询数据,将数据放到map里面,自定义的excel的单元格里获取map的key值
List> listMap = new ArrayList>();
for(int i=0;i
Map ma = new HashMap();
ma.put("xh", String.valueOf(i+1));
ma.put("mygs", list.get(i).getGs());
ma.put("kjmc", list.get(i).getMineName());
ma.put("dd", list.get(i).getLocation());
ma.put("zdz", list.get(i).getNowmaxvalue());
ma.put("zdzsk", list.get(i).getNowtime());
ma.put("three", list.get(i).getTheaybeforeValue());
ma.put("two", list.get(i).getTwodaysagoValue());
ma.put("one", list.get(i).getTheaybeforeValue());
ma.put("nowzdz", list.get(i).getNowmaxvalue());
listMap.add(ma);
}
map.put("listmap", listMap);
modelMap.put(TemplateExcelConstants.FILE_NAME, "河南能源化工集团安全监控系统联网系统瓦斯涌出异常信息表"); //文件名
modelMap.put(TemplateExcelConstants.PARAMS, params);//参数
modelMap.put(TemplateExcelConstants.MAP_DATA, map);//数据
return TemplateExcelConstants.JEECG_TEMPLATE_EXCEL_VIEW;//view名称
SpringWeb中,需要在spring-mvc.xml中引入处理Excel的配置
导出结果