PHP教程:php导入到excel-支持utf8和gbk两种编码

php导入到excel-支持utf8和gbk两种编码

php导入到excel乱码是因为utf8编码在xp系统不支持所有utf8编码转码一下就完美解决了

utf-8编码案例

<?php 
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=www.niutw.com.xls '); 
header('Content-Transfer-Encoding: binary '); 
?> 
<? 
$filename='php导入到excel-utf-8编码'; 
$filename=iconv('utf-8', 'gb2312', $filename); 
echo $filename; 
?>

gbk编码案例

<?php 
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=www.iiwnet.com.xls '); 
header('Content-Transfer-Encoding: binary '); 
?> 
<? 
$filename='php导入到excel-utf-8编码'; 
echo $filename; 
?>

访问网站的时候就下载到excel里面

要弄单元格区别的话

用table表格做网页的就可以了

更多:PHP教程

转载于:https://my.oschina.net/xixios/blog/83486

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值