Using maatwebsite I have to generate the 'xlsx' file and attach the same in the email through mailable or direct mail attachment.
By default the file is stored in storage folder which I don't want.
Ignored the export or download method at the end of the script and assigned that Excel::create in a variable.
$file = Excel::create($fileName, function($excel) use($valuesInArray) {
$excel->sheet('Sheetname', function($sheet) use($valuesInArray) {
$sheet->fromArray($valuesInArray);
});
});
Mail::send('email.documents_export',["user"=>"Albert", "clientName" => "AAA"],function($m) use($file){
$m->to('albert@aaa.com')->subject('Document Export');
$m->attach($file->store("xlsx",false,true)['full']);
});
File has to be available for attachment without store it anywhere.