码迷,mamicode.com
首页 > 其他好文 > 详细

poi excel export 乱码

时间:2016-04-22 18:22:53      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

1. Question Description:

  ~前端是get方式提交的,参数含有中文“测试”   

  ~导出的excel,文件名正常, 而标题乱码

 

2. Solution:

    ~断点发现, 参数接收就是乱码,

    ~String excelTitle = new String(objectgroupname.getBytes("ISO-8859-1"), "utf-8");

    ~HSSFSheet sheet = book.createSheet(excelTitle);//sheet的名字

    ~response.reset();
        response.setContentType("application/vnd.ms-excel;charset=utf-8");
        String filename = objectgroupname + ".xls";
        response.setHeader("Content-Disposition", "attachment;filename="+ filename);
        response.setCharacterEncoding("utf-8");

  ~原来传过来的不作处理,再传回浏览器就不是乱码。

 

poi excel export 乱码

标签:

原文地址:http://www.cnblogs.com/rocky-fang/p/5422215.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!