Laravel-excel: Multiple Sheets not working if any/all sheet implements FromView

Created on 26 Mar 2018  ·  3Comments  ·  Source: Maatwebsite/Laravel-Excel

Prerequisites

  • [ ] Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • [X] Checked that your issue isn't already filed.
  • [X] Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 7.2
  • Laravel version: 5.5
  • Package version: 3.0.1

Description

Multiple Sheets not working if any/all sheets are FromView

  • all sheets implementing FromView (not working)
  • 1 sheet FromView and another implementing FromCollection (not working)
  • all sheets not implementing FromView (working fine)

Steps to Reproduce (attaching my codes)

`
class FormatReportExport implements WithMultipleSheets, Responsable
{
use Exportable;

protected $reports;
protected $summary;

public function __construct($summary, $reports)
{
    $this->summary = $summary;
    $this->reports = $reports;
}

public function sheets(): array
{
    $sheets = [];

    $sheets[] = new ReportSummaryExport($this->summary);
    $sheets[] = new ReportExport($this->reports);

    return $sheets;
}

}
`

`
class ReportSummaryExport implements FromCollection, WithTitle
{
protected $summary;

public function __construct($summary)
{
    $this->summary = $summary;
}


public function collection()
{
    return User::get();
}

/**
 * @return string
 */
public function title(): string
{
    return 'Summary';
}

}`

`class ReportExport implements FromView, WithTitle
{
protected $reports;

public function __construct($reports)
{
    $this->reports = $reports;
}

public function view(): View
{
    return view('export.report.list', [
        'title' => $this->title(),
        'reports' => $this->reports
    ]);
}

/**
 * @return string
 */
public function title(): string
{
    return 'Checklists';
}

}`

list.blade.php
`@extends('layouts.export', ['title' => $title])

@section('content')

@foreach($reports as $report) @endforeach
Date Created
{{ $report['created_at'] }}

@endsection`

Expected behavior:

Excel file with multiple sheets based on the views.

Actual behavior:

image

bug

Most helpful comment

All 3 comments

Thanks for submitting the ticket. We will pick it up as soon as we have resources available (as stated in our support guidelines (https://laravel-excel.maatwebsite.nl/docs/3.0/getting-started/support)).

Will most likely be solved by #1590

Was this page helpful?
0 / 5 - 0 ratings

Related issues

disto picture disto  ·  3Comments

vandolphreyes picture vandolphreyes  ·  3Comments

kevinRR picture kevinRR  ·  3Comments

matthewslouismarie picture matthewslouismarie  ·  3Comments

octoxan picture octoxan  ·  3Comments