导出csv文件用excel打开乱码怎么解决,用记事本另存ansi编码之后正常,这个可以在代码里面改写直接转换吗?
於CsvExporter.php
public function export()
{
.....
$headers = [
'Content-Encoding' => 'UTF-8',
'Content-Type' => 'text/csv;charset=UTF-8',
'Content-Disposition' => "attachment; filename=\"$filename\"",
];
echo "\xEF\xBB\xBF"; //<====== 多加這一段
response(rtrim($output, "\n"), 200, $headers)->send();
exit;
}
Most helpful comment
於CsvExporter.php