Home >Backend Development >PHP Tutorial >PHP imports utf8, gbk encoding into Excel_PHP tutorial

PHP imports utf8, gbk encoding into Excel_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:34:441247browse

Import php to excel-supports both utf8 and gbk encodings

The reason why php imports garbled characters into excel is because utf8 encoding does not support all utf8 encoding in the xp system. It can be perfectly solved by transcoding

utf-8 encoding case

header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream"); ​​
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename=11.xls ");
header("Content-Transfer-Encoding: binary ");
?>
$filename="php import to excel-utf-8 encoding";
$filename=iconv("utf-8", "gb2312", $filename);
echo $filename;
?>

gbk encoding case

header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream"); ​​
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename=11.xls ");
header("Content-Transfer-Encoding: binary ");
?>
$filename="php import to excel-utf-8 encoding";
echo $filename;
?>

Download it to excel when you visit the website

If you want to distinguish between cells

Just use tables to make web pages

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/508436.htmlTechArticlephp import to excel-supports both utf8 and gbk encoding php import to excel garbled because utf8 encoding is in xp system All utf8 encodings are not supported. Can the utf-8 encoding case be solved perfectly by transcoding? php h...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn