использовать пакет Excel
use Excel;
Здесь вы можете передавать данные
$getdata = values from database or directly get from user.
$headings= you have to pass heading of each column
Экспорт данных в Excel
public function getExport($get_data, $headings)
{
Excel::create(('excel name', function ($excel) use ($get_data, $headings) {
$excel->sheet('Sheet 1', function ($sheet) use ($get_data, $headings) {
$sheet->fromArray($get_data, null, 'A1', false, false);
$sheet->prependRow(1, $headings);
});
})->export('xls');
}