Java导出Excel表(poi)名中文乱码问题处理

时间:2021-10-30 01:10:50

<pre name="code" class="java">String _filename = ValidateTools.date2Str(date, "yyyyMMddHHmmss");
String filename = f_name + _filename;
HSSFSheet sheet;
HSSFCell cell;

response.setContentType("application/x-download");//下面三行是关键代码,处理乱码问题
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment;filename="+new String(filename.getBytes("gbk"), "iso8859-1")+".xls");
sheet = workbook.createSheet("sheet1");


Java导出Excel表名中文乱码问题处理的关键代码