0
我想更改列標題的名稱。 你好嗎?Laravel with Maatwebsite
這是在控制器代碼:
public function excelterima($nm_perusahaan){
if($user = Auth::user()->admin == 2){
$users = Mstbeasiswa::select('NO_ANGGOTA', 'NM_ANGGOTA', 'GOLONGAN', 'NPK', 'CABANG', 'NM_ANAK', 'NM_SKL', 'id')
->where('flag_terima', '1')
->where('NM_PERUSAHAAN', $nm_perusahaan)
->orderBy('id', 'asc')
->get()->toArray();
//work on the export
Excel::create($nm_perusahaan, function($excel) use ($users){
$excel->sheet('sheet 1', function($sheet) use ($users)
{
$sheet->fromArray($users);
ob_end_clean();
});
})->download('xlsx');
return redirect('/beasiswaditerima');
}else{
return redirect('/home');
}
}
輸出電流:
如果需要,您可以在查詢中使用'select ... AS'來實現此目的。 – Ohgodwhy
謝謝:) ................. –