在 Laravel Excel 文档中找不到如何在 download() 之后重定向()。我尝试过这样做
Excel::load('/bills/bill.template.xlsx', function($doc) {
$sheet = $doc->setActiveSheetIndex(0);
$sheet->setCellValue('G21', '{buyer}');
})->download('xlsx');
return redirect('/')->with('notification','custom msg');
但它不起作用。
最佳答案
似乎无法完成,但您可以尝试解决类似问题的解决方法:
How do I redirect after download in Laravel?
基本上,您首先重定向回最终页面,然后启动下载:
Session::flash('download.in.the.next.request', 'filetodownload.pdf');
return Redirect::to('/');
然后在你看来会是这样的:
<html>
<head>
@if(Session::has('download.in.the.next.request'))
<meta http-equiv="refresh" content="5;url={{ Session::get('download.in.the.next.request') }}">
@endif
<head>
<body>
...
</body>
</html>
查看上面的链接以获取更多说明。
关于php - 如何使用 Laravel Excel 在 ->download() 之后重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34186306/