导出excel乱码

阅读更多

 

out.clear();
response.reset();
response.setContentType("application/vnd.ms-excel;charset=utf-8");
String fileName = "fileName/中文";
response.setHeader("Content-Disposition","attachement;filename="+new String (fileName.getBytes("gb2312"),"ISO-8859-1")+ ".xls;");

 导出excel

重点在这句:

 

(fileName.getBytes("gb2312"),"ISO-8859-1")
或者
URLEncoder.encode(fileName,"UTF-8")

你可能感兴趣的:(导出excel乱码)