本文介紹了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();
任何幫助專家?
附注.文件以標題/編碼 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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!