$filename = '.xlsx';
Excel::store(new UsersExport, $filename);
$path = storage_path($filename);
Try giving it an actual filename, not just an extension.
'report.xlsx' for example
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
$filename = '.xlsx';
Excel::store(new UsersExport, $filename);
$path = storage_path($filename);
Try giving it an actual filename, not just an extension.
'report.xlsx' for example
@FTIERSCH - yes i try this
$filename = "Sales Register 2019 Cr.xlsx";
Excel::store(new UsersExport,$filename);
$path = storage_path($filename);
yes mail was sent but excel file correupted not valid extesnion like error while excel file open
@FTIERSCH - here is my full code
$filename = "Sales Register 2019 Cr.xlsx";
Excel::store(new UsersExport,$filename);
$path = storage_path($filename);
$data = array('name'=>"byte and bits");
\Mail::send('front.mail', $data, function($message) use($path){
$message->to('[email protected]')
->subject('Sales Register 2019 Excelsheet');
$message->from('[email protected]','byte and bits');
$message->attach($path);
});
Can you open the file that gets saved on your harddrive?
@FTIERSCH - yes file is open
when i try to open excel file
error like "excel cannot open file 'sales register.xlsx' beacuse the file format or file extension is not valid. verify that the file extesnion matches the format of the file"
like error
Yes, but that error comes only when you open the file in the email or also when you open the file it saved on your disk?
Forget all about Excel for a minute try to send any file just practice sending email correctly first, with an attachment.
Maybe you're trying to cram too much into one operation.
After you can definitely email an attachment then the next step is to practice importing an Excel file but do not attempt to do anything else yet.
Just make sure you have imported correctly and can read the file nothing else yet.
Then and only then send it as an attachment.
That Github package has been around for a while, so if you slow down and just work those examples slowly you will learn this stuff.
By time this post has had so many questions and answers you could have worked several of the examples and learned.
And above, I mean import or export or whatever.
@FTIERSCH - yes excalty
@JLRDW - simple attachment successfully send but while i try export file send mail error popup
"exactly" is not an answer to an "or" question ;) Which one is it?
@FTIERSCH - file open in mail or disk then error fetch
error like "excel cannot open file 'sales register.xlsx' beacuse the file format or file extension is not valid. verify that the file extesnion matches the format of the file"
Yes, I've seen the error. But it happens at both times. So your export is wrong.
https://github.com/Maatwebsite/Laravel-Excel/issues/202
Maybe this helps
@FTIERSCH - my file export sucessfully
but i send file in mail then mail file downlaod and like issue error fetching
So you can open the exported file inside your Laravel directory?
@FTIERSCH - no i exported file in public folder not in laravel directory
actually i found problem is mail
i try to mail send but not currect path to store file then is error is curreputed file message
problem is in code
$filename = "Sales Register 2019 Cr.xlsx";
Excel::store(new UsersExport,$filename);
$path = storage_path($filename);
dd($path);
i try dd to display "D:\laragon\www\hello\storage\Sales Register 2019 Cr.xlsx"
not file fetch only storage path fetch
actually i try to fetch exported file
@SNAPEY - i actually my mistake i cannot properly understand maatwebsite packages for readymate code
to how to store see
Excel::store(new UsersExport(2018), 'Sales Register 2019 Cr.xlsx');
readymate code but i am new in laravel so i cannot properly understand how its work
sorry @snapey @jlrdw @ftiersch
thanks for helping and guiding as
@van1310 ,
Kindly can you paste all code the way you import file and send email with attachment
I have the same case.
Please or to participate in this conversation.