본문 바로가기

개발중/Java

액셀 / 액셀 파일 한글 깨져요.

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
반응형