php标头Excel和utf-8 [英] php header excel and utf-8

查看:101
本文介绍了php标头Excel和utf-8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

What I'm getting in the excel file is Désçàui

但是,尝试时确实会得到Désçàui

However, I do get Désçàui when I try

ob_start();
echo 'Désçàui';
header("Content-Type:   text/html; charset=utf-8");
ob_end_flush();

有任何帮助专家吗?

PS.该文件以标题/编码Unicode(Utf-8)保存在DW中.

PS. The file is saved in DW with Title/Encoding Unicode(Utf-8).

推荐答案

我不确定,但是excel可能无法处理utf8(可能取决于版本).但是它可以处理utf16,因此请尝试转换字符集. 这对我有用(在excel2002中):

I'm not sure, but it may be that excel can not handle utf8(may depend on the version). But it can handle utf16, so try converting the charset. This works for me(in excel2002):

echo mb_convert_encoding('Désçàui','utf-16','utf-8');

这篇关于php标头Excel和utf-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆