首页 > 其他 > 详细

POI_excel下载_中文名_浏览器兼容解决

时间:2016-08-10 18:54:13      阅读:128      评论:0      收藏:0      [点我收藏+]
private void downfile(HSSFWorkbook wb,String ua,String fileName,HttpServletResponse response)
throws IOException {
String agent = ua;//request.getHeader("user-agent");
if(agent.contains("Firefox")){ // 火狐浏览器
fileName = "=?UTF-8?B?"+new BASE64Encoder().encode(fileName.getBytes("utf-8"))+"?=";
}else{ // IE及其他浏览器
fileName = URLEncoder.encode(fileName,"utf-8");
}
response.setHeader("content-disposition", "attachment;filename=" + fileName + ".xls");
OutputStream fos = response.getOutputStream();
wb.write(fos);
fos.close();
}

POI_excel下载_中文名_浏览器兼容解决

原文:http://www.cnblogs.com/kingsniper13/p/5757725.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!