Reputation: 439
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.
But when I open it using Notepad++ or upload to Google Drive, I got exactly I want.
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;
}
}
}
Upvotes: 2
Views: 3673
Reputation: 1
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.
Upvotes: 0
Reputation: 439
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 !
Upvotes: 4