Laravel-excel: UTF-8 encoding in CSV export?

Created on 2 Nov 2016  ·  4Comments  ·  Source: Maatwebsite/Laravel-Excel

When I export my CSV file, I would like to export it as an UTF-8 encoded CSV file as you can do in Microsoft Excel and soforth.

Package version, Laravel version

Laravel 4.2

Expected behaviour

In the CSV characters like æ, ø and å should be displayed in stead of engsøparken and soforth.

Actual behaviour

In stead of outputting "engsøparken", it outputs "engsøparken".

Screenshot of Excel file

screen shot 2016-11-02 at 14 32 03

Most helpful comment

Same issue here. Laravel 5.2 and controller is an UTF-8 file. Please, reopen :laughing:

All 4 comments

This package exports UTF-8 by default. Please check if your application is configured correctly.

Same issue here. Laravel 5.2 and controller is an UTF-8 file. Please, reopen :laughing:

Just got it working with these settings. Everything is UTF-8.
A CSV is exported and opened with Excel 2010. German Umlauts are shown correctly.
They were shown wrong before, when use_bom was false.

[
   'exports' => [
       …
       'csv'                    => [
            'delimiter'              => ';',
            'enclosure'              => '"',
            'line_ending'            => PHP_EOL,
            'use_bom'                => true,
            'include_separator_line' => false,
            'excel_compatibility'    => false,
        ],
    ]
]
       return Excel::download(
            new MyExport($data), "{$slug}.csv",
            \Maatwebsite\Excel\Excel::CSV
        );

Just got it working with these settings. Everything is UTF-8.
A CSV is exported and opened with Excel 2010. German Umlauts are shown correctly.
They were shown wrong before, when use_bom was false.

[
   'exports' => [
       …
       'csv'                    => [
            'delimiter'              => ';',
            'enclosure'              => '"',
            'line_ending'            => PHP_EOL,
            'use_bom'                => true,
            'include_separator_line' => false,
            'excel_compatibility'    => false,
        ],
    ]
]
       return Excel::download(
            new MyExport($data), "{$slug}.csv",
            \Maatwebsite\Excel\Excel::CSV
        );

This worked for me, thanks!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ellej16 picture ellej16  ·  3Comments

muhghazaliakbar picture muhghazaliakbar  ·  3Comments

vandolphreyes picture vandolphreyes  ·  3Comments

matthewslouismarie picture matthewslouismarie  ·  3Comments

contifico picture contifico  ·  3Comments