java輸出response流檔案,配合vue進行excel流檔案下載
阿新 • • 發佈:2019-01-27
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 ();
}