PHP导出excel 中文乱码

1、设置header头

header("Content-type: application/vnd.ms-excel; charset=UTF-8"); // 文件编码

header("Content-type: application/octet-stream");//流文件

header("Content-Disposition:attachment;filename = xxx.csv" );

2、输出

$fp = fopen('php://output', 'w');

fprintf($fp, chr(0xEF).chr(0xBB).chr(0xBF)); // 设置编码的文件头

fputcsv($fp, $arr);

posted @ 2021-04-27 14:43  羽*枫  阅读(353)  评论(0)    收藏  举报