1、response方式返回excel文件流@GetMapping("/exportExcel") public void exportExcel(@RequestParam(value = "menu") String menu, @RequestParam(value = "dwflglId") int dwflglId, @RequestParam(value = "qjCode") String qjCode, HttpServletResponse response) throws IOException { //内容集合 List jthz = getJthz(dwflglId, qjCode); //表头集合 List header = getHeaderOfHz(dwflglId, qjCode); response.setHeader("Content-Disposition", "attachment; filename=Zjlryshz.xlsx"); // 响应类型,编码 response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); String bigTitle = "资金流入预算表"; EasyExcel.write(response.getOutputStream()).head(getExcelHeader(header, bigTitle)).registerWriteHandler(new Custemhandler()).sheet("资金流入预算导出模板").doWrite(getExportData(jthz)); }2、通过在服务器中生成excel临时文件,返回下载