lundi 29 octobre 2018

How to send collection as an excel file in laravel

I'm using Laravel Excel 3.1 from https://laravel-excel.maatwebsite.nl/ and I am trying to figure out if there is a simple way to simply render a collection as an excel file.

In my controller, I have code that generates a db query and puts it into a view. I'd like to give the user the ability to download the data in that view as an excel document. The code used to create the view is not simple, and it is based on many query inputs.

In my controller, I have

public function excelExport(Request $request)
{
    $params = $this->getQueryParams($request);
    $pts = $this->createIndexCollection($request, $params);

    return Excel::download(new PatientsExport, 'patients.xlsx');
}

I'd like to pass the already-computed collection $pts to the download command. Is this possible?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire