ob_start();
echo 'Désçàui';
header("Content-Type: application/vnd.ms-excel; charset=utf-8");
header("Content-type: application/x-msexcel; charset=utf-8");
header("Content-Disposition: attachment; filename=Test.xls");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
ob_end_flush();
我在Excel文件中得到的是Désçà ui
然而,当我尝试时,我确实得到了 Désçàui
ob_start();
echo 'Désçàui';
header("Content-Type: text/html; charset=utf-8");
ob_end_flush();
有专家帮忙吗?
附言。文件以标题/编码 Unicode(Utf-8) 保存在 DW 中。
Source http://www.mwasif.com/2007/5/download-data-csv-using-php/ http://www.mwasif.com/2007/5/download-data-csv-using-php/
解决方案对我有用
丹麦人扎胡尔说,
2009 年 10 月 7 日 @ 晚上 7:23
如果您的内容是UTF-8格式,则无需转换编码。只需在标头后使用 UTF-8 BOM 启动文件/输出流即可。
echo pack("CCC",0xef,0xbb,0xbf);
并且标头应包含编码 UTF-8
header( "Content-type: application/vnd.ms-excel; charset=UTF-8" );
它会像魅力一样工作,因为 Excel 将识别带有 BOM 字节的文件字符集。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)