close

이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.

linux/php

php엑셀 한글깨짐

mysop 2021. 11. 5. 15:33
728x90
반응형

보통 아래와 같이 

PHP로 엑셀파일을 변환 시켜 다운로드 받게 만든다

header("Content-type: application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename="파일명.xls");
header("Content-Description:PHP4 Generated Data");

 

그런데

 

MAC, 윈도우 다 잘 나오는데

 

리눅스 리브레오피스 (LIBREOFFICE)에서 한글이 깨진다고 한다..

 

 

망할 리브레 @%^&%

 

방법은 간단하다..

 

print("<meta http-equiv=\"Content-Type\" content=\"application/vnd.ms-excel; charset=utf-8\">");

위 태그 하나 더 넣어주자...

 

 

다시 말해서

header("Content-type: application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename="파일명.xls");
header("Content-Description:PHP4 Generated Data");   
print("<meta http-equiv=\"Content-Type\" content=\"application/vnd.ms-excel; charset=utf-8\">");

 

이렇게 넣어주면 된다.

 

출처 : http://egloos.zum.com/superb1204/v/3271374

 

PHP 엑셀다운로드 시 한글 깨질 경우

깨질때의 헤더- header( "Content-type: application/vnd.ms-excel" ); header( "Content-Disposition: attachment; filename=$_POST[filename].xls" ); header( "Content-Description: PHP4 Generated Data" ); header

egloos.zum.com

 

728x90
반응형