发新话题
打印

导出EXCEL时,文件名中有空格等,会出现乱码.修改了一下

导出EXCEL时,文件名中有空格等,会出现乱码.修改了一下

在ReportExporter.java文件,export方法中,将文件名中的字符做了替换.

        String file = getFileName(job, ext);
        
        //特殊字符处理
        file=URLEncoder.encode(file, "UTF-8");        
        file = file.replaceAll("\\+", "%20").replaceAll("%28", "\\(").replaceAll("%29", "\\)").replaceAll("%3B", ";").replaceAll("%40", "@").replaceAll("%23", "\\#").replaceAll("%26", "\\&");

        response.setContentType("application/x-filler");
        response.setHeader("Content-Disposition",
            "attachment;filename=" + file);

TOP

谢谢这位朋友.:)

TOP

发新话题