2

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

我使用 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;
        }
    }
}
4

1 回答 1

2

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

希望这有帮助!

于 2017-08-18T08:51:22.997 回答