Tharindu Prabodhana
Tharindu Prabodhana

Reputation: 301

Export process work but no file downloaded [ Maatwebsite / Laravel-Excel ]

Description

I am trying to export excel file. I do all things in the documentation and the process work with no errors. but the excel file does not download.. I'm using Ubuntu OS.

UserExport.php

<?php

 namespace App\Exports;

 use App\User;
 use Maatwebsite\Excel\Concerns\FromCollection;

 class UsersExport implements FromCollection
 {
    /**
     */
     public function collection()
     {
         return User::all();
      }
  } 

ExportExcelController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Exports\UsersExport;

use Maatwebsite\Excel\Facades\Excel;

class ExportExcelController extends Controller
{
    public function export() 
    {

        return Excel::download(new UsersExport, 'users.xlsx');
    }
}

Upvotes: 3

Views: 2367

Answers (2)

F KIng
F KIng

Reputation: 498

I was using the package with inertia-vue and using an <a></a> in place of the <Link></Link> tag worked the trick

Upvotes: 0

Jake Killpack
Jake Killpack

Reputation: 107

I was seeing the same behavior. I got around it by clearing out all caches and recreating the config cache.

php artisan cache:clear
php artisan route:clear
php artisan view:clear
php artisan config:cache

Upvotes: 0

Related Questions