>  기사  >  백엔드 개발  >  xls가 PHP에서 잘못된 문자를 내보내는 경우 수행할 작업

xls가 PHP에서 잘못된 문자를 내보내는 경우 수행할 작업

藏色散人
藏色散人원래의
2022-11-24 09:20:031760검색

PHP의 xls에서 내보낸 잘못된 문자에 대한 해결 방법: 1. 해당 PHP 파일을 엽니다. 2. 잘못된 문자를 생성하는 파일에 "header("Content-type:application/vnd.ms-excel;charset=UTF)를 추가합니다. -8 ");" 문으로 충분합니다.

xls가 PHP에서 잘못된 문자를 내보내는 경우 수행할 작업

이 튜토리얼의 운영 환경: Windows 7 시스템, PHP 버전 8.1, Dell G3 컴퓨터.

PHP에서 xls 내보내기가 왜곡되면 어떻게 해야 하나요?

phpmyadmin 처리 방법 사용

<?php 
header("Content-type:application/vnd.ms-excel;charset=UTF-8"); 
header("Content-Disposition: attachment; filename=$filename"); 
header("Pragma: no-cache"); 
header("Expires: 0"); 
?> 
//这个很关键

관련 소개:

콘텐츠 유형 유형은

<?php
$mimetypes = array(
&#39;ez&#39; => &#39;application/andrew-inset&#39;,
&#39;hqx&#39; => &#39;application/mac-binhex40&#39;,
&#39;cpt&#39; => &#39;application/mac-compactpro&#39;,
&#39;doc&#39; => &#39;application/msword&#39;,
&#39;bin&#39; => &#39;application/octet-stream&#39;,
&#39;dms&#39; => &#39;application/octet-stream&#39;,
&#39;lha&#39; => &#39;application/octet-stream&#39;,
&#39;lzh&#39; => &#39;application/octet-stream&#39;,
&#39;exe&#39; => &#39;application/octet-stream&#39;,
&#39;class&#39; => &#39;application/octet-stream&#39;,
&#39;so&#39; => &#39;application/octet-stream&#39;,
&#39;dll&#39; => &#39;application/octet-stream&#39;,
&#39;oda&#39; => &#39;application/oda&#39;,
&#39;pdf&#39; => &#39;application/pdf&#39;,
&#39;ai&#39; => &#39;application/postscript&#39;,
&#39;eps&#39; => &#39;application/postscript&#39;,
&#39;ps&#39; => &#39;application/postscript&#39;,
&#39;smi&#39; => &#39;application/smil&#39;,
&#39;smil&#39; => &#39;application/smil&#39;,
&#39;mif&#39; => &#39;application/vnd.mif&#39;,
&#39;xls&#39; => &#39;application/vnd.ms-excel&#39;,
&#39;ppt&#39; => &#39;application/vnd.ms-powerpoint&#39;,
&#39;wbxml&#39; => &#39;application/vnd.wap.wbxml&#39;,
&#39;wmlc&#39; => &#39;application/vnd.wap.wmlc&#39;,
&#39;wmlsc&#39; => &#39;application/vnd.wap.wmlscriptc&#39;,
&#39;bcpio&#39; => &#39;application/x-bcpio&#39;,
&#39;vcd&#39; => &#39;application/x-cdlink&#39;,
&#39;pgn&#39; => &#39;application/x-chess-pgn&#39;,
&#39;cpio&#39; => &#39;application/x-cpio&#39;,
&#39;csh&#39; => &#39;application/x-csh&#39;,
&#39;dcr&#39; => &#39;application/x-director&#39;,
&#39;dir&#39; => &#39;application/x-director&#39;,
&#39;dxr&#39; => &#39;application/x-director&#39;,
&#39;dvi&#39; => &#39;application/x-dvi&#39;,
&#39;spl&#39; => &#39;application/x-futuresplash&#39;,
&#39;gtar&#39; => &#39;application/x-gtar&#39;,
&#39;hdf&#39; => &#39;application/x-hdf&#39;,
&#39;js&#39; => &#39;application/x-javascript&#39;,
&#39;skp&#39; => &#39;application/x-koan&#39;,
&#39;skd&#39; => &#39;application/x-koan&#39;,
&#39;skt&#39; => &#39;application/x-koan&#39;,
&#39;skm&#39; => &#39;application/x-koan&#39;,
&#39;latex&#39; => &#39;application/x-latex&#39;,
&#39;nc&#39; => &#39;application/x-netcdf&#39;,
&#39;cdf&#39; => &#39;application/x-netcdf&#39;,
&#39;sh&#39; => &#39;application/x-sh&#39;,
&#39;shar&#39; => &#39;application/x-shar&#39;,
&#39;swf&#39; => &#39;application/x-shockwave-flash&#39;,
&#39;sit&#39; => &#39;application/x-stuffit&#39;,
&#39;sv4cpio&#39; => &#39;application/x-sv4cpio&#39;,
&#39;sv4crc&#39; => &#39;application/x-sv4crc&#39;,
&#39;tar&#39; => &#39;application/x-tar&#39;,
&#39;tcl&#39; => &#39;application/x-tcl&#39;,
&#39;tex&#39; => &#39;application/x-tex&#39;,
&#39;texinfo&#39; => &#39;application/x-texinfo&#39;,
&#39;texi&#39; => &#39;application/x-texinfo&#39;,
&#39;t&#39; => &#39;application/x-troff&#39;,
&#39;tr&#39; => &#39;application/x-troff&#39;,
&#39;roff&#39; => &#39;application/x-troff&#39;,
&#39;man&#39; => &#39;application/x-troff-man&#39;,
&#39;me&#39; => &#39;application/x-troff-me&#39;,
&#39;ms&#39; => &#39;application/x-troff-ms&#39;,
&#39;ustar&#39; => &#39;application/x-ustar&#39;,
&#39;src&#39; => &#39;application/x-wais-source&#39;,
&#39;xhtml&#39; => &#39;application/xhtml+xml&#39;,
&#39;xht&#39; => &#39;application/xhtml+xml&#39;,
&#39;zip&#39; => &#39;application/zip&#39;,
&#39;au&#39; => &#39;audio/basic&#39;,
&#39;snd&#39; => &#39;audio/basic&#39;,
&#39;mid&#39; => &#39;audio/midi&#39;,
&#39;midi&#39; => &#39;audio/midi&#39;,
&#39;kar&#39; => &#39;audio/midi&#39;,
&#39;mpga&#39; => &#39;audio/mpeg&#39;,
&#39;mp2&#39; => &#39;audio/mpeg&#39;,
&#39;mp3&#39; => &#39;audio/mpeg&#39;,
&#39;aif&#39; => &#39;audio/x-aiff&#39;,
&#39;aiff&#39; => &#39;audio/x-aiff&#39;,
&#39;aifc&#39; => &#39;audio/x-aiff&#39;,
&#39;m3u&#39; => &#39;audio/x-mpegurl&#39;,
&#39;ram&#39; => &#39;audio/x-pn-realaudio&#39;,
&#39;rm&#39; => &#39;audio/x-pn-realaudio&#39;,
&#39;rpm&#39; => &#39;audio/x-pn-realaudio-plugin&#39;,
&#39;ra&#39; => &#39;audio/x-realaudio&#39;,
&#39;wav&#39; => &#39;audio/x-wav&#39;,
&#39;pdb&#39; => &#39;chemical/x-pdb&#39;,
&#39;xyz&#39; => &#39;chemical/x-xyz&#39;,
&#39;bmp&#39; => &#39;image/bmp&#39;,
&#39;gif&#39; => &#39;image/gif&#39;,
&#39;ief&#39; => &#39;image/ief&#39;,
&#39;jpeg&#39; => &#39;image/jpeg&#39;,
&#39;jpg&#39; => &#39;image/jpeg&#39;,
&#39;jpe&#39; => &#39;image/jpeg&#39;,
&#39;png&#39; => &#39;image/png&#39;,
&#39;tiff&#39; => &#39;image/tiff&#39;,
&#39;tif&#39; => &#39;image/tiff&#39;,
&#39;djvu&#39; => &#39;image/vnd.djvu&#39;,
&#39;djv&#39; => &#39;image/vnd.djvu&#39;,
&#39;wbmp&#39; => &#39;image/vnd.wap.wbmp&#39;,
&#39;ras&#39; => &#39;image/x-cmu-raster&#39;,
&#39;pnm&#39; => &#39;image/x-portable-anymap&#39;,
&#39;pbm&#39; => &#39;image/x-portable-bitmap&#39;,
&#39;pgm&#39; => &#39;image/x-portable-graymap&#39;,
&#39;ppm&#39; => &#39;image/x-portable-pixmap&#39;,
&#39;rgb&#39; => &#39;image/x-rgb&#39;,
&#39;xbm&#39; => &#39;image/x-xbitmap&#39;,
&#39;xpm&#39; => &#39;image/x-xpixmap&#39;,
&#39;xwd&#39; => &#39;image/x-xwindowdump&#39;,
&#39;igs&#39; => &#39;model/iges&#39;,
&#39;iges&#39; => &#39;model/iges&#39;,
&#39;msh&#39; => &#39;model/mesh&#39;,
&#39;mesh&#39; => &#39;model/mesh&#39;,
&#39;silo&#39; => &#39;model/mesh&#39;,
&#39;wrl&#39; => &#39;model/vrml&#39;,
&#39;vrml&#39; => &#39;model/vrml&#39;,
&#39;css&#39; => &#39;text/css&#39;,
&#39;html&#39; => &#39;text/html&#39;,
&#39;htm&#39; => &#39;text/html&#39;,
&#39;asc&#39; => &#39;text/plain&#39;,
&#39;txt&#39; => &#39;text/plain&#39;,
&#39;rtx&#39; => &#39;text/richtext&#39;,
&#39;rtf&#39; => &#39;text/rtf&#39;,
&#39;sgml&#39; => &#39;text/sgml&#39;,
&#39;sgm&#39; => &#39;text/sgml&#39;,
&#39;tsv&#39; => &#39;text/tab-separated-values&#39;,
&#39;wml&#39; => &#39;text/vnd.wap.wml&#39;,
&#39;wmls&#39; => &#39;text/vnd.wap.wmlscript&#39;,
&#39;etx&#39; => &#39;text/x-setext&#39;,
&#39;xsl&#39; => &#39;text/xml&#39;,
&#39;xml&#39; => &#39;text/xml&#39;,
&#39;mpeg&#39; => &#39;video/mpeg&#39;,
&#39;mpg&#39; => &#39;video/mpeg&#39;,
&#39;mpe&#39; => &#39;video/mpeg&#39;,
&#39;qt&#39; => &#39;video/quicktime&#39;,
&#39;mov&#39; => &#39;video/quicktime&#39;,
&#39;mxu&#39; => &#39;video/vnd.mpegurl&#39;,
&#39;avi&#39; => &#39;video/x-msvideo&#39;,
&#39;movie&#39; => &#39;video/x-sgi-movie&#39;,
&#39;ice&#39; => &#39;x-conference/x-cooltalk&#39;,
);
?>

권장 학습: "PHP 비디오 튜토리얼"

위 내용은 xls가 PHP에서 잘못된 문자를 내보내는 경우 수행할 작업의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.