0

我遇到了一个奇怪的问题,我无法强制 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:: 方法,但我不熟悉它。

4

1 回答 1

0

在链接中设置目标“_blank”使这项工作。

于 2016-04-29T18:28:32.647 回答