分享:php生成csv文件的header设置,如下:
复制代码 代码示例:
$csvContent = "qwe,qwe,qwe,qwe,qwe,qwe,qwe /n";
header("Content-Type: application/vnd.ms-excel; charset=GB2312");
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename=CSV数据.csv ");
header("Content-Transfer-Encoding: binary ");
$csvContent = iconv("utf-8","gb2312",$csvContent);
echo $csvContent;
exit;
?>
更多内容,请参考:
PHP header函数用法举例
php header函数用法详解举例(2)
php header函数用法举例(1)
php中header函数的用法举例详解
php header 使用详解
php header头信息应用举例
php生成csv文件