可参考博文:https://blog.csdn.net/xiyang_1990/article/details/130831286
总结:
// 关于文件名的输出
public void export(@RequestBody List<ReportStatisticsDto> dto, HttpServletResponse response) throws Exception {
String fileName = "xxx.xlsx";
response.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8"));
ServletOutputStream out = response.getOutputStream();
xxxxxService.writeXXXXList(out, dto);
}