HSSFWorkbook wb = ExcelExportUtil.toExportHos(new String[]{"title1", "title2", "title3", "title4", "title5", "title6"},hosList); response.setContentType("application/vnd.ms-excel;charset=UTF-8"); response.setCharacterEncoding("UTF-8"); try { response.setHeader("Content-Disposition", "attachment;filename="+ java.net.URLEncoder.encode("excelName.xls","UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } try { OutputStream os = response.getOutputStream(); wb.write(os); os.flush(); os.close(); wb = null; }catch(IOException e){ e.printStackTrace(); }
引用 3 楼 bc_aptx4869 的回复:建议直接使用response流下载哦,我这边也是springboot项目,就是利用resoonse流直接输出到前端,前端再用blob大对象解析就行了,你想用的话我发你源码 大佬能把源码贴出来看下吗?
建议直接使用response流下载哦,我这边也是springboot项目,就是利用resoonse流直接输出到前端,前端再用blob大对象解析就行了,你想用的话我发你源码
67,549
社区成员
225,860
社区内容
加载中
试试用AI创作助手写篇文章吧