poi 3.8 导出excel 乱码

yuanfangyuyu 2012-06-14 04:37:56
在weblogic下 poi3.8 导出excel数据,中文会成乱码
但在tomcat下是正常的,各位求解,谢谢!
...全文
426 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuanfangyuyu 2012-06-15
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 的回复:]
String downloadName = "表名.xls";
downloadName = new String(downloadName.getBytes(), "ISO8859-1");
response.setHeader("Content-disposition", "attachment;filename=" + downloadName);
response.setConten……
[/Quote]

试用你的方法也不行,

是导出的内容出现乱码,
xiejin90314 2012-06-15
  • 打赏
  • 举报
回复
String downloadName = "表名.xls";
downloadName = new String(downloadName.getBytes(), "ISO8859-1");
response.setHeader("Content-disposition", "attachment;filename=" + downloadName);
response.setContentType("application/x-download");

ServletOutputStream servletOutputStream = response.getOutputStream();
wb.write(servletOutputStream);
servletOutputStream.flush();
servletOutputStream.close();
yuanfangyuyu 2012-06-15
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]
这是我昨天刚解决的问题,看对你有没有帮助

Java code


try {
// fileName = new String(fileName.getBytes("UTF-8"), "UTF-8");
//if (request.getHeader("User-Agent").toLowerCase().indexOf("firefo……
[/Quote]

依旧不可行
kunger309 2012-06-15
  • 打赏
  • 举报
回复
这是我昨天刚解决的问题,看对你有没有帮助

try {
// fileName = new String(fileName.getBytes("UTF-8"), "UTF-8");
//if (request.getHeader("User-Agent").toLowerCase().indexOf("firefox") > 0)

fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器

// else
//
// if (request.getHeader("User-Agent").toUpperCase().indexOf("MSIE") > 0)
//
// fileName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
} catch (UnsupportedEncodingException e) {
// should no happen
}
System.out.println(fileName);
response.reset();
response.setContentType("application/msexcel;charset=UTF-8");
response.setHeader("Content-disposition", "attachment;filename= " + fileName);
}
yuanfangyuyu 2012-06-15
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]
JSP里面所有是UTF-8
[/Quote]

jsp是GBK的
yuanfangyuyu 2012-06-15
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
response.setContentType("application/msexcel;charset=UTF-8");
[/Quote]

以上方法试用,没有起任何效果
  • 打赏
  • 举报
回复
JSP里面所有是UTF-8

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧