I am having a weird issue where I can't force Laravel to automatically download an exported sheet.
I know that the sheet is being generated because after I click on the link (at the bottom) I am taken to a blank page -- if I hit refresh on that page I automatically download the sheet I just exported and it looks fine. All I want to do is have the sheet automatically download but stay on the home page.
My Controller:
public function ListAll()
{
Excel::create('Users', function($excel) {
$excel->sheet('Users', function($sheet) {
$users = User::orderBy('End_Enrollment','asc')->get();
$sheet->fromArray($users);
});
})->export('xlsx'); // Have also tried ->download('xlsx') and have same issue.
return View::make('/');
}
My routes:
Route::get('/all', 'SearchController@ListAll');
The link on the website (html):
Click <a href="/all">here</a> to export the entire database.
I have read about a Response:: method, but I am unfamiliar with it.
Setting target"_blank" in the link made this work.