php - 如何使用 Laravel Excel 在 ->download() 之后重定向

标签 php excel laravel

在 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/

相关文章:

php - 计算特定日期之间的选票

php - 如何使用 LOAD DATA INFILE 命令在 MySQL 中输入特殊字符

vba - Excel VBA : Can I query external excel without opening the target file?

excel - 我可以从启用所有宏的 .cmd 脚本运行 Excel 吗?

excel - 在 Powerpoint 中插入 Excel 内容。错误消息: Clipboard is empty or contains data which may not be pasted here

php - 如何根据条件执行计数(*)作为总数

php - 如何从 Magento 中删除意外创建的货件?

php - 如何将我的数据从一个按钮返回到另一个 php 页面

laravel - 使用 Laravel Passport 的 SSO

javascript - 如何在Vue JS中使用element ui进行分页?