Closed daraghoshea closed 9 years ago
1.3.0 will have the ability to pass an array of headers as the 2nd parameter of the export()
method:
->export('xls', [
'Set-Cookie' => 'fileDownload=true; path=/'
]);
How can I do this with version 3.1?
@andreshg112 you can add the use Exportable;
Concern to the class e.g.
class MyExportClass implements FromView
{
use Exportable;
}
Then in your controller you can add the header:
return (new MyExportClass())->download('myexportfile.xlsx', \Maatwebsite\Excel\Excel::XLSX, [
'X-Vapor-Base64-Encode' => 'True'
]);
Documentation is here, took me a bit to figure out as well: https://docs.laravel-excel.com/3.1/exports/exportables.html
@conradfuhrman That worked! You my friend saved my sanity today 🤘
In order to facilitate the use of a jquery plugin that implements an ajax like downloading experience: http://johnculviner.com/jquery-file-download-plugin-for-ajax-like-feature-rich-file-downloads
The implementation requires a particular header to be sent back as part of the server side response which currently cannot be done within the
LaravelExcelWriter::_download()
method.Utilising an event prior to sending headers would allow the default headers to be flexibly adjusted as required.