gpt4 book ai didi

php - 拉维尔 : UTF-8 issue while exporting CSV

转载 作者:行者123 更新时间:2023-12-01 22:22:48 25 4
gpt4 key购买 nike

在尝试从数据库导出数据时,我看到了一些垃圾值,而不是显示 UTF-8 字符的实际数据。我用 Excel 打开 csv,我用了 Maatwebsite/Laravel-Excel用于导出 csv 的包。

这是我的 Controller :

public function downloadExcel($type)
{
$data = Item::get()->toArray();
return Excel::create('solutionstuff_example', function($excel) use ($data) {

header('Content-Encoding: UTF-8');
header('Content-type: text/csv; charset=UTF-8');
header('Content-Disposition: attachment; filename=solutionstuff_example.csv');
$excel->sheet('mySheet', function($sheet) use ($data)
{
$sheet->fromArray($data);
});
})->download($type);
}

截图如下:

enter image description here

如果有人遇到问题并且知道如何解决它。希望你能帮助我解决它。谢谢

最佳答案

我已经解决了问题:

我改变了值(value):'use_bom'=>false'use_bom'=>true

在 config 文件夹中 excel.php 文件的 'csv' 部分。祝你成功!

图像细节:

enter image description here

关于php - 拉维尔 : UTF-8 issue while exporting CSV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38929492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com