导出CSV,无论是什么格式,excel打卡都是乱码
需要加上
echo "xEFxBBxBF";
header("Content-Disposition:attachment;filename=$fileName.csv");
header("Content-Type:$exportType;charset=UTF-8");
header("Expires: Mon, 31 Dec 2000 00:00:00 GMT" );
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
header("Cache-Control: post-check=0, pre-check=0", false );
$header = implode("", "", $headers);
$header = """ .$header;
$header .= ""
";
echo "xEFxBBxBF";
echo $header;
foreach($entries as $row) {
foreach ($row as $key => $value) {
/* To support double quotations in CSV format
* To review: http://creativyst.com/Doc/Articles/CSV/CSV01.htm#EmbedBRs
*/
$row[$key] = str_replace('"', '""', $value);
}
$line = implode("","",$row);
$line = """ .$line;
$line .= ""
";
echo $line;
}