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

PierreZA's avatar

Spatie Laravel Excel unit testing multiple sheets

Heyo,

We use spatie's Laravel Excel package for importing from and exporting to Excel and they have some limited testing on their documentation https://docs.laravel-excel.com/3.1/exports/testing.html. I am struggling to test if an export was correctly downloaded because the export uses multiple sheets. so the export itself literally only has a construct method and a sheets() method. I could not find anything else online. Thanks

Edit: currently doing an export with 5 sheets.

0 likes
3 replies
Elliot_putt's avatar

Instead of testing, import the actual data and see if the entry got imported that you added to the excel sheets. Looks like you need to get the file into the request and pass it that way or else put an absolute path.

$path = $request->file("csv")->getRealPath();
            $import = new AssetImport;
            $import->import($path, null, \Maatwebsite\Excel\Excel::CSV);
PierreZA's avatar

@Elliot_putt oh nooo, i put the wrong link. Im trying to test an export with multiple sheets. I was thinking i could maybe test each sheet individually but the export does have 5 sheets

Elliot_putt's avatar

@PierreZA hmm okay could you paste your export controller function and export class ? I am correct in saying you want to export an excel file with multiple sheets?

Please or to participate in this conversation.