标签:
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();
}
标签:
原文地址:http://www.cnblogs.com/kingsniper13/p/5757725.html