作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在尝试从数据库导出数据时,我看到了一些垃圾值,而不是显示 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);
}
截图如下:
如果有人遇到问题并且知道如何解决它。希望你能帮助我解决它。谢谢
最佳答案
我已经解决了问题:
我改变了值(value):'use_bom'=>false
到'use_bom'=>true
在 config 文件夹中 excel.php
文件的 'csv'
部分。祝你成功!
图像细节:
关于php - 拉维尔 : UTF-8 issue while exporting CSV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38929492/
我正在使用 git clone 部署我的 Laravel 项目并使用 git pull 进行更新 它工作正常,但每次部署时,我都必须从 config/app.php providers 数组和 ali
我是一名优秀的程序员,十分优秀!