Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在laravel中导出带有自定义标题和多张图纸的excel_Php_Laravel - Fatal编程技术网

Php 在laravel中导出带有自定义标题和多张图纸的excel

Php 在laravel中导出带有自定义标题和多张图纸的excel,php,laravel,Php,Laravel,我正在尝试使用laravel excel导出,其中有自定义标题。有点像这样: 我使用的是LaravelExcel3,使用的是FromQuery,带标题,带标题 我能够使用WithHeaders数组实现所需输出的一半,但其余部分无法实现 <?php namespace App\Exports; use Modules\Report\Entities\Aereport; use Maatwebsite\Excel\Concerns\FromQuery; u

我正在尝试使用laravel excel导出,其中有自定义标题。有点像这样:

我使用的是LaravelExcel3,使用的是FromQuery,带标题,带标题

我能够使用WithHeaders数组实现所需输出的一半,但其余部分无法实现

<?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',                        
        ];
    }
}

您是否尝试过使用查看->excel导出选项。您可以在blade视图中创建一个html表,并将其直接导出到excel。我也有同样的想法,但我也希望使用多个工作表进行导出。关于如何使用视图实现这一点,有什么线索吗?还是别的什么?