2016-04-29 53 views
0

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

我知道工作表正在生成,因为我点击链接后(在底部)我被带到一个空白页面 - 如果我在该页面上刷新,我会自动下载我刚刚导出的工作表和它看起来不错。我想要做的就是让工作表自动下载,但留在主页上。

我的控制器:

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', '[email protected]'); 

网站上的链接(HTML):

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

我已阅读有关响应::方法,但我并不熟悉它。

回答