【问题标题】:Error unicode export csv file - Laravel/Excel错误 unicode 导出 csv 文件 - Laravel/Excel
【发布时间】:2018-01-26 20:19:15
【问题描述】:

我有问题,你们能帮帮我吗?

我使用 Maatwebsite/Laravel-excel 将日文文本从数据库导出到 csv 文件。

当我使用 MS Excel 打开导出文件时,我得到了很多符号。

但是当我使用 Notepad++ 打开它或上传到 Google Drive 时,我得到了我想要的。

我该如何解决?

这是我的代码:

    public function export($type, $properties, $data)
{
    if (in_array($type, self::EXPORT_TYPE)) {
        try {
            $export = Excel::create($properties['_title'], function ($excel) use ($data, $properties) {
                $excel->sheet('Sheet', function ($sheet) use ($data) {
                    foreach ($data as $item) {
                        $sheet->fromArray($item);
                    }
                });
            })->export('csv');
        } catch (Exception $error) {
            throw $error;
        }
    }
}

【问题讨论】:

    标签: php csv laravel-5 export maatwebsite-excel


    【解决方案1】:

    我解决了。 如果有人遇到此问题,请尝试编辑 config/excel.php :将 'use_bom' => false 更改为 'use_bom' => true

    希望这有帮助!

    【讨论】:

    • 谢谢。有效。顺便说一句,你能解释一下到底发生了什么吗?
    猜你喜欢
    • 2013-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-18
    • 2019-02-14
    • 2019-05-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多