response.setCharacterEncoding("UTF-8"); response.setContentType("application/ms-excel"); String fileName = "数据-" + timeStr + ".xlsx"; try { fileName = java.net.URLEncoder.encode(fileName, "UTF-8"); // 这句很重要,不然文件名为乱码 } catch (UnsupportedEncodingException e) { e.printStackTrace(); } ExcelUtils.exportExcel(excelList, "数据", "数据", ExcelToGongyuHouseVillageEntity.class, fileName, response);
response.setContentType("application/vnd.ms-excel;charset=gb2312");
试试这个
你不要用web环境 ,直接本地写个main方法跑一下,就可以判断出来了。