IT/PHP

[PHP] 엑셀 다운로드 파일 한글 깨짐 현상

월공 2020. 8. 26. 13:25
728x90
300x250

PHP 에서 엑셀 파일로 다운로드했을때에 파일내에 한글이 깨지는 현상이 발생

 

header( "Content-type: application/vnd.ms-excel; charset=euc-kr");
header( "Content-Disposition: attachment; filename=$file_name" );
header( "Content-Description: PHP4 Generated Data" );
print("<meta http-equiv=\"Content-Type\" content=\"application/vnd.ms-excel; charset=euc-kr\">");

해결 방법을 찾아보니 위 처럼 소스를 수정하라고 하는데 난 잘안됐다

결국은 아래 소스로 해결

header( "Content-type: application/vnd.ms-excel;charset=UTF-8");
header( "Expires: 0" );
header( "Cache-Control: must-revalidate, post-check=0,pre-check=0" );
header( "Pragma: public" );
header( "Content-Disposition: attachment; filename=TEST_".date('Ymd').".xls" );

도움이 되었으면 좋겠습니다 ~~~!!

728x90
300x250