PHPでxlsで文字化けをエクスポートした場合の対処方法

藏色散人
リリース: 2023-03-17 14:46:02
オリジナル
1766 人が閲覧しました

php の xls からエクスポートされた文字化けしたコードの解決策: 1. 対応する PHP ファイルを開きます; 2. 文字化けしたコードを生成するファイルに、「header("Content-type:application/vnd.ms- Excel;charset =UTF-8");" ステートメントで十分です。

PHPでxlsで文字化けをエクスポートした場合の対処方法

このチュートリアルの動作環境: 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"); 
?> 
//这个很关键
ログイン後にコピー

関連紹介:

Content-type type has

<?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 ビデオ チュートリアル

以上がPHPでxlsで文字化けをエクスポートした場合の対処方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート