OutputStream out = getResponse().getOutputStream();
getResponse().setHeader("Content-disposition", "attachment;filename="+ URLEncoder.encode("1.html", "UTF-8"));
getResponse().setContentType("application/msexcel;charset=UTF-8");
out.write(replaceContent.toString().getBytes());
out.flush();
out.close();
//replaceContent 为下载的内容
//1.html 为下载的名字
//POI导出流文件下载
public static void downloadExcel(HSSFWorkbook workbook,HttpServletResponse response, String filename) throws IOException {
try {
OutputStream out = response.getOutputStream();
response.setHeader("Content-disposition", "attachment;filename="+ URLEncoder.encode(filename, "UTF-8"));
response.setContentType("application/msexcel;charset=UTF-8");
workbook.write(out);
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}