728x90
반응형
액셀 파일 한글 깨져요.
String fileName = "한글테스트.xlsx";
fileName = URLEncoder.encode(fileName, "UTF-8");
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\";");
시도 1
String fileName = "한글테스트.xlsx";
fileName = new String(fileName.getBytes("utf-8"),"8859_1") + ".xls";
fileName = URLEncoder.encode(fileName, "UTF-8");
response.setCharacterEncoding("UTF-8");
시도 2
String fileName = "한글테스트.xlsx";
fileName = URLEncoder.encode(fileName, "UTF-8");
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Disposition", "attachment;filename="+new String(fileName.getBytes("euc-kr"),"8859_1")+".xlsx");
시도 3
String fileName = "한글테스트.xlsx";
fileName = URLEncoder.encode(fileName, "euc-kr");
response.setCharacterEncoding("euc-kr");
response.setHeader("Content-Disposition", "attachment;filename="+new String(fileName.getBytes("euc-kr"),"8859_1")+".xlsx");
시도 4
String fileName = "한글테스트.xlsx";
fileName = new String(fileName.getBytes("KSC5601"), "8859_1");
response.setCharacterEncoding("euc-kr");
response.setHeader("Content-Disposition", "attachment;filename="+new String(fileName.getBytes("euc-kr"),"8859_1")+".xlsx");
시도 5
String fileName = "한글테스트.xlsx";
fileName = new String(fileName.getBytes("KSC5601"), "8859_1");
response.setCharacterEncoding("KSC5601");
response.setHeader("Content-Disposition", "attachment;filename="+new String(fileName.getBytes("KSC5601"),"8859_1")+".xlsx");
시도 6
String fileName = "한글테스트.xlsx";
fileName = new String(fileName.getBytes("KSC5601"), "8859_1");
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Disposition", "attachment;filename="+new String(fileName.getBytes("UTF-8"),"8859_1")+".xlsx");
728x90
반응형
'개발중 > Java' 카테고리의 다른 글
Java - String 날짜형 Type 검사 (0) | 2021.05.17 |
---|---|
LOMBOK - NoArgsConstructor/AllArgsConstructor 사용 (0) | 2021.05.14 |
액셀 다운로드 - '~~.xlsx' 의 내용에 문제가 있습니다 (0) | 2021.05.13 |
lombok / getter setter 대소문자 호환 오류 (0) | 2021.05.13 |
액셀 / AbstractXlsxView - setContentType (0) | 2021.05.13 |