ProjectDepreciationMultipleSheetExport.php 762 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Exports;
  3. use Maatwebsite\Excel\Concerns\WithMultipleSheets;
  4. class ProjectDepreciationMultipleSheetExport implements WithMultipleSheets
  5. {
  6. protected $data; // 格式:[ '2025-RD01' => [ 'project_name' => '...', 'months' => [ 1 => [...数据...], 2 => [...] ] ] ]
  7. public function __construct(array $data)
  8. {
  9. $this->data = $data;
  10. }
  11. public function sheets(): array
  12. {
  13. $sheets = [];
  14. foreach ($this->data as $groupKey => $payload) {
  15. // $groupKey 比如 "2025-RD01"
  16. $sheets[] = new ProjectDepreciationSheetExport(
  17. $groupKey,
  18. $payload['project_name'],
  19. $payload['months']
  20. );
  21. }
  22. return $sheets;
  23. }
  24. }