While trying to export data form database I saw some garbage value instead of showing the actual data which is UTF-8 character. I used Excel for opening the csv and I used Maatwebsite/Laravel-Excel package for exporting the csv.
Here is my controller :
public function downloadExcel($type)
{
$data = Item::get()->toArray();
return Excel::create('solutionstuff_example', function($excel) use ($data) {
header('Content-Encoding: UTF-8');
header('Content-type: text/csv; charset=UTF-8');
header('Content-Disposition: attachment; filename=solutionstuff_example.csv');
$excel->sheet('mySheet', function($sheet) use ($data)
{
$sheet->fromArray($data);
});
})->download($type);
}
Here is snap of it:
If anybody face the problem and know how to fix it.Hope you'll help me to solve it. Thanks