@RequestMapping("/exportOperateLog")
@ResponseBodypublic voidexportOperateLog(HttpServletRequest request, HttpServletResponse response, OperateLogParam param) {
SimpleDateFormat dateFormat= new SimpleDateFormat("yyyyMMddHHmmss");try{
response.reset();
response.setContentType("text/html;charset=GBK");//设置response内容的类型
response.setHeader("Content-disposition", "attachment;filename=SysteamLog" + dateFormat.format(new Date()) + ".xls;");
String strTableName= "系统日志"; //这个是标题
List headers = new ArrayList<>();
headers.add("序号"); //这里的表头,根据数据的字段命名也行,随你喜欢
headers.add("操作日期时间");
headers.add("操作类型");
headers.add("数据1");
headers.add("数据2");
headers.add("操作员id");
headers.add("操作员");
List operateLogList =operateLogService.findOperateLogList(param);
List operateListStr = new ArrayList<>();for (int i = 0; i < operateLogList.size(); i++) {
OperateLogParam opeLogPar=operateLogList.get(i);
String[] strarr= new String[]{(StringUtils.isEmpty(opeLogPar.getOperateLogId().toString())?"-":opeLogPar.getOperateLogId().toString()),
(StringUtils.isEmpty(opeLogPar.getCreateTime().toString())?"-":opeLogPar.getCreateTime().toString()),
(StringUtils.isEmpty(opeLogPar.getTitle())?"-":opeLogPar.getTitle()),
(StringUtils.isEmpty(opeLogPar.getData1())?"-":opeLogPar.getData1()),
(StringUtils.isEmpty(opeLogPar.getData2())?"-":opeLogPar.getData2()),
(StringUtils.isEmpty(opeLogPar.getAdminId().toString())?"-":opeLogPar.getAdminId().toString()),
(StringUtils.isEmpty(opeLogPar.getOperatorName())?"-":opeLogPar.getOperatorName()),
};
operateListStr.add(strarr);
}
ExcelUtil.createExcel(strTableName, headers, operateListStr, response.getOutputStream());
}catch(IOException e) {
e.printStackTrace();
}