public void exportUserList(HttpServletResponse response){
List<User> users = userService.findAll(null, null);
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), User.class, users);
try {
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(new Date().getTime()+".xls", "utf-8"));
ServletOutputStream out = response.getOutputStream();
workbook.write(out);
} catch (IOException e) {
e.printStackTrace();
}
}
文件下载对应的content-type或Mime-Type类型对照表可自行百度