안녕하세요 게시물을 엑셀로 다운받으려고 하는데
테이블로 만드니까 th부분이 한글이 깨져요..ㅜ
charset을 utf-8, euc-kr 로 해도 깨져요 ㅠㅠ
어떻게 해야할까요..
Copy
<?php
include_once "_common.php";
if (!$is_admin) {
alert("관리자만 접근 가능합니다.");
exit;
}
$excel_down = $g5['write_customer'] . $_GET['bo_table']; //엑셀 다운로드 테이블
$wr_id = $_GET['wr_id'];
$hp_filename = "문의현황";
@sql_query("SET CHARACTER SET utf-8"); // 한글깨지면 주석해지
if ($ms =="excel"){
$g5['title'] = "엑셀 문서 다운로드";
header( "Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" );
header( "Content-Disposition: attachment; filename={$hp_filename}.xlsx" );
//header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="power"){
$g5['title'] = "파워포인트 문서 다운로드";
header( "Content-type: application/vnd.ms-powerpoint" );
header( "Content-Disposition: attachment; filename={$hp_filename}.ppt" );
// header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="word"){
$g5['title'] = "워드 문서 다운로드";
header( "Content-type: application/vnd.ms-word" );
header( "Content-Disposition: attachment; filename={$hp_filename}.doc" );
//header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="memo"){
$g5['title'] = "메모 문서 다운로드";
header( "Content-type: application/vnd.ms-notepad" );
header( "Content-Disposition: attachment; filename={$hp_filename}.txt" );
} else {
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename={$hp_filename}.xls" );
}
header( "Content-Description: PHP4 Generated Data" );
print("<meta http-equiv=\"Content-Type\" content=\"application/vnd.ms-excel; charset=utf-8\">");
// 원글 + 코멘트 다운로드
$temp=sql_fetch_array(sql_query("select count(*) from {$excel_down} "));
$result=sql_query("select * from {$excel_down} order by wr_datetime desc");
// 원글만 다운로드 (코멘트 제외) , 2013-10-21 추가
//$temp=sql_fetch_array(mysql_query("select count(*) from {$excel_down} where wr_is_comment = '0' and wr_content = '{$wr_id}' "));
//$result=sql_query("select * from {$excel_down} where wr_is_comment = '0' and wr_content = '{$wr_id}' order by wr_datetime desc");
$number=$temp[0];
?>
<html>
<head>
<!-- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
.txt {
mso-style-parent:style0;
mso-number-format:"\@";
border:.5pt solid windowtext;
}
</style>
</head>
<body>
<table>
<tr>
<th class='txt'>고객명</th>
<th class='txt'>전화번호</th>
<th class='txt'>건물유형</th>
<th class='txt'>입주일</th>
<th class='txt'>요청사항</th>
<!-- <td>필드1</td>
<td>필드2</td>
<td>필드3</td>
<td>필드4</td>
<td>필드5</td>
<td>필드6</td>
<td>필드7</td>
<td>필드8</td>
<td>필드9</td>
<td>필드10</td>
</tr> -->
<?php
while($data=sql_fetch_array($result)) {
echo "
<tr>
<td class='txt'>{$data['wr_subject']}</td>
<td class='txt'>{$data['wr_1']}</td>
<td class='txt'>{$data['wr_2']}</td>
<td class='txt'>{$data['wr_3']}</td>
<td class='txt'>{$data['wr_4']}</td>
</tr>
";
$number--;
}
?>
</table>
</body>
</html>
답변 6개 / 댓글 1개
채택된 답변
+20 포인트
th부분이 한글이 깨져요....
==
HTML (PHP) 파일 자체 chatset을 확인해 보세요.
<style type="text/css">
.txt {
mso-style-parent:style0;
mso-number-format:"\@";
border:.5pt solid windowtext;
font-family: 'Malgun Gothic', '맑은 고딕', 'Arial', sans-serif; /* 한글 폰트 지정 */
}
</style>
스타일 타입 해보시구요.
만약 않되면 헤더파일 열어서 이렇게 해보세요
header("Content-Type: application/vnd.ms-excel; charset=utf-8");
Copy
if ($ms =="excel"){
$g5['title'] = "엑셀 문서 다운로드";
header( "Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" );
header( "Content-Disposition: attachment; filename={$hp_filename}.xlsx" );
이부분을
if ($ms =="excel"){ $g5['title'] = "엑셀 문서 다운로드";
header('Content-Type: application/vnd.ms-excel; charset=utf-8');
header( "Content-Disposition: attachment; filename={$hp_filename}.xlsx" );
이렇게 해보세요.
답변을 작성하려면 로그인이 필요합니다.