强制Laravel 4.2使用Laravel Excel自动下载导出的工作表


Forcing Laravel 4.2 to auto-download exported sheet using Laravel-Excel

我遇到了一个奇怪的问题,无法强制Laravel自动下载导出的工作表。

我知道正在生成工作表,因为在我点击链接(底部)后,我会进入一个空白页面——如果我在该页面上点击刷新,我会自动下载我刚刚导出的工作表,它看起来很好。我所想做的就是让表格自动下载,但保持在主页上。

我的控制器:

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('/');
}

我的路线:

Route::get('/all', 'SearchController@ListAll');

网站上的链接(html):

Click <a href="/all">here</a> to export the entire database.

我读过一篇关于Response::方法的文章,但我不熟悉它。

在链接中设置目标"_blank"使此操作成功。