2

I have a problem, can you guys help me ?

I use Maatwebsite/Laravel-excel to export japanese text from database to csv file.

When I open export file using MS Excel, I got a lot of symbols.

enter image description here

But when I open it using Notepad++ or upload to Google Drive, I got exactly I want.

enter image description here

How can I fix it ?

This is my code :

    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;
        }
    }
}

2 Answers 2

4

I solved it. if any one get this problem, try edit config/excel.php : change 'use_bom' => false to 'use_bom' => true.

Hope this helpful !

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. It worked. Btw can you explain what exactly is happening?
0

You shouldn't edit the config file of Maatwebsite library. Because in production environment, Maatwebsite will be update whenever you run command compose install/update. So your config is also false.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.