<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表名中文乱码问题处理的关键代码
时间: 2024-10-05 13:21:03