| 1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace App\Exports;
- use Maatwebsite\Excel\Concerns\WithMultipleSheets;
- class MultiSheetExport implements WithMultipleSheets
- {
- protected $data;
- protected $type;
- protected $column;
- protected $timeRow;
- public function __construct(array $data, int $type = 1, array $column, array $timeRow)
- {
- $this->data = $data;
- $this->type = $type;
- $this->column = $column;
- $this->timeRow = $timeRow;
- }
- public function sheets(): array
- {
- $sheets = [];
- foreach ($this->data as $sheetName => $sheetData) {
- // 将 type 传给 SingleSheetExport
- $sheets[] = new SingleSheetExport($sheetData, $sheetName, $this->type, $this->column, $this->timeRow);
- }
- return $sheets;
- }
- }
|