2023년 3월 17일 금요일

HTML - 엑셀 다운로드 시 한글 깨짐 현상 (여러가지 처리 방법)


<ASP - euc-kr 기준>

[#1]

<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=euc-kr">
or
<meta http-equiv="content-type" content="text/html; charset=euc-kr"> 


[#2]

Response.Buffer = True
Response.CharSet = "euc-kr"
'Response.CacheControl = "public"
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;filename=엑셀파일명.xls"


[#3]

Session.CodePage = 949



<ASP - utf-8 기준>

[#1]

<meta http-equiv="Content-Language" content="ko">

FileName = Server.urlEncode("한글깨짐방지")
or
FileName = Server.URLPathEncode("한글깨짐방지")




<C# 기준>


[#1]

<meta name="viewport" http-equiv="Content-Type" content="text/html; charset=utf-8" />
or
<meta name="viewport" http-equiv="Content-Type" content="text/html; charset=euc-kr" />


[#2]

Response.Charset = "euc-kr";   
Response.ContentType = "application/vnd.ms-excel"; 
Response.ContentEncoding = System.Text.Encoding.GetEncoding("euc-kr"); 


[#3]

Response.Clear();
Response.ClearHeaders();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment; filename=" + "파일명_" + DateTime.Now.ToString("yyyy_MM_dd") + ".xls");
Response.Charset = "utf-8";
Response.ContentType = "application/vnd.xls";
 
string table = @"<Table><tr><td>111</td></tr><tr><td>222</td></tr></Table>";
Response.Write(table);
Response.End();











댓글 없음:

댓글 쓰기

javascript - SQL 예약어 제거

  <script language="javascript"> //특수문자, 특정문자열(sql예약어) 제거 function checkSearchedWord(obj){ obj.value = obj.value+&quo...