Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ligonsker's avatar

Can I pass the data from the created Excel file to the listener with Laravel-Excel?

Hello,

I registered a global event in AppServiceProvider as per the docs: https://docs.laravel-excel.com/3.1/exports/extending.html#global-event-listeners :

Writer::listen(BeforeWriting::class, function () {
    //
});

Can I get the data from the exported file?

For example if the event was triggered by the download method, then get the filename:

public function export() 
{
    return Excel::download(new InvoicesExport, 'invoices.xlsx');
}

So in the listener I will be able to get invoices.xlsx

Thanks

0 likes
0 replies

Please or to participate in this conversation.