js要怎么接收后端传的excel文件流?

各位大佬好,我有一个同事后端写了这么一端excel文件输出代码,请问我前端js要怎么接收?

Workbook workbook = exportExcel(lsMap, ExcelType.HSSF);
request.setCharacterEncoding("utf-8");
respones.setCharacterEncoding("utf-8");
respones.setContentType("application/x-download");
String filedisplay = "product.xls";
filedisplay = URLEncoder.encode(filedisplay, "utf-8");
respones.addHeader("Content-Disposition", "attachment;filename=" + filedisplay);
OutputStream out = respones.getOutputStream();
workbook.write(out);
out.close();

方法1: 无需js,直接用a标签去接你的输出流

下载

方法2:使用js,前提是你使用的是现代浏览器,支持html5特性(主要是新的XMLHTTPRequest对象,Blob)



你可能感兴趣的:(C#,前端)