Экспорт в Excel с пользовательскими заголовками и несколькими листами в laravel - PullRequest
0 голосов
/ 31 мая 2019

Я пытаюсь экспортировать, используя laravel excel, где у меня есть пользовательские заголовки. Примерно так:

enter image description here

Я использую Laravel Excel 3, используя FromQuery, WithTitle, WithHeadings.

Я могу получить половину желаемого результата с помощью массива withheadings, но оставшаяся часть недостижима

<?php

    namespace App\Exports;

    use Modules\Report\Entities\Aereport;
    use Maatwebsite\Excel\Concerns\FromQuery;
    use Maatwebsite\Excel\Concerns\WithTitle;
    use Maatwebsite\Excel\Concerns\WithHeadings;
    use Maatwebsite\Excel\Concerns\ShouldAutoSize;

    class AereportPerDaySheet implements FromQuery, WithTitle, WithHeadings, ShouldAutoSize
    {
        private $year;
        private $day;
        private $month;

        public function __construct(int $year, int $month, int $day)
        {
            $this->year = $year;
            $this->day = $day;
            $this->month  = $month;
        }

        /**
         * @return Builder
         */
        public function query()
        {   
            return     Aereport::select('report_id','dateofreport','date','url','username','reportertype','productname','verbatim','priority','aeraised')->whereMonth('dateofreport', $this->month)->whereday('dateofreport', $this->day);

        }

    /**
     * @return string
     */
    public function title(): string
    {
        return $this->day .' '. date("F", mktime(0,0,0,$this->month,1)) .' '. $this->year;
    }
    public function headings(): array
    {
        return[
            'Id',
            'Date issue was found',
            'URL',
            'Username',
            'Reporter Type',
            'Product Name',
            'Verbatim',
            'Priority',                        
        ];
    }
}

enter image description here

Как показано, я могу получить заголовки, но не указанные настройки.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...