java输出response流文件,配合vue进行excel流文件下载

版权声明:Yes, I still love you, let me accompany you around, staged an impossible love https://blog.csdn.net/bc_aptx4869/article/details/82217808
HSSFWorkbook wb = ExcelExportUtil.toExportHos(new String[]{"管理机构", "医院编码", "医院名称", "医院等级", "年案件量", "目标医院状态"},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("医院信息数据导出.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();
}

猜你喜欢

转载自blog.csdn.net/bc_aptx4869/article/details/82217808