php excel下载乱码,用的PHPExcel 下载出现乱码的問題

编码问题,解决方法:

一、开头加上一句:

header("Content-Type:text/html;charset=GB2312");

同时把你页面中的“ $cellvalue=iconv("gbk","UTF-8",$content...”的utf-8也统一为GB2312试试!

二、也可改用下面办法,不用$Excelobj=new PHPExcel();对象,而是直接输出html格式(只是把扩展名改为.xsl),因为excel,word本身是很好的html编辑器,能直接解释html标签:

//如果是xsl,word等则更简单,只需直接在原来的php文件开头加上下面几句:

header("Content-Type: application/force-download");//提示下载,而不是直接打开!

if( $sExport == "excel"){

header("ContentType = application/vnd.ms-excel");

header("Content-Disposition: attachment; filename=".$oTitle.".xls");

}

if( $sExport == "word"){

echo ("

收文登记簿

");

header("ContentType = application/vnd.ms-word");//或试试 application/msword

header("Content-Disposition: attachment; filename=".$oTitle.".doc");

}

if( $sExport == "csv"){

header("ContentType = application/csv"); //图像image/jpeg",或image/*"

header("Content-Disposition: attachment; filename=".$oTitle.".csv");

}

//.....输出原来的php代码

取消

评论

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值