@ApiOperation("导出历史上送记录")
@PostMapping(value = "/exportSend", produces = "application/octet-stream")
public void exportExcel(@RequestBody ExportSendVO sendVO, HttpServletResponse response) throws Exception {
// 获取数据
List<MessageExportVO> result = ssMessageManageService.exportSend(sendVO);
// 设置 HTTP 响应头信
response.setContentType("application/vnd.ms-excel");
response.setHeader("Access-Control-Expose-Headers","Content-Disposition");
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("历史上送记录.xlsx", "utf-8"));
response.setCharacterEncoding("utf-8");
// 使用 EasyExcel 写入数据到响应的输出流
EasyExcel.write(response.getOutputStream(), MessageExportVO.class)
.sheet("历史上送记录")
.doWrite(result);
}
注意点!!!!
定义的VO类 处理时间
<!--easy-excel-->标签:application,EasyExcel,导出,sendVO,result,简单,response From: https://www.cnblogs.com/yzxsx/p/18325266
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.0.5</version>
</dependency>
导入依赖