【问题标题】:Error exporting Excel file in Laravel using Maatwebsite\Excel使用 Maatwebsite\Excel 在 Laravel 中导出 Excel 文件时出错
【发布时间】:2021-12-07 16:03:04
【问题描述】:

我在 Laravel 中导出到 Excel 文件时出错。我做错了什么

消息错误 #message: "Method Illuminate\View\View::mergeCells 确实 不存在。”

namespace App\Exports;

use Maatwebsite\Excel\Concerns\FromCollection;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;

class TimekeepingExport implements FromView
{
    public function __construct($data)
    {
        $this->data = $data;
    }

    /**
     * @return \Illuminate\Support\Collection
     */
    public function view(): View
    {
        return view('backend.timekeeping.export-temp', [
            'items' => $this->data['items'],
            'detail' => $this->data['detail'],
            'getDays' => $this->data['getDays'],
            'getDates' => $this->data['getDates'],
            'total_day_request' => $this->data['total_day_request'],
        ])->mergeCells('A1:E1');
    }
}

【问题讨论】:

  • 欢迎来到 SO ... mergeCells 必须在“工作表”上调用
  • 我想使用视图导出。我可以使用 mergeCells 吗??
  • 您可以使用视图导出,但 mergeCells 调用必须在工作表上而不是视图上,您​​必须弄清楚要覆盖或定义的方法,以允许您访问表对象调用它

标签: excel laravel maatwebsite-excel


【解决方案1】:

正如错误消息所示,“mergeCells”不是 Illuminate\View\View 类的有效方法,因此您不能将其添加到视图返回的末尾。

【讨论】:

  • 你能帮我吗??
猜你喜欢
  • 2019-05-20
  • 2018-10-23
  • 2019-04-17
  • 2016-11-23
  • 1970-01-01
  • 2021-12-29
  • 1970-01-01
  • 2019-05-15
  • 2020-09-04
相关资源
最近更新 更多