使用easyexcel
@ApiOperation("导出")
@PostMapping("/export")
public void export(HttpServletRequest request,
HttpServletResponse response,
@RequestBody ColumnStandardExportParamDTO columnStandardExportParamDTO){
List<Long> ids = columnStandardExportParamDTO.getIds();
List<ColumnStandardExportDTO> listToExport = dataGovColumnStandardService.findByIds(ids);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
try {
EasyExcel.write(response.getOutputStream(), ColumnStandardExportDTO.class)
.sheet("字段标准").doWrite(listToExport);
} catch (IOException e) {
log.error("下载导入模板异常", e);
}
}