File: D:/HostingSpaces/SBogers10/hours.komma.pro/app/Komma/Excel/Types/Exports/HoursExport.php
<?php
namespace App\Komma\Excel\Types\Exports;
use App\Komma\Excel\Types\Row\HourRow;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithTitle;
use Maatwebsite\Excel\Events\AfterSheet;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
class HoursExport implements FromView, ShouldAutoSize, WithTitle, WithColumnFormatting, WithEvents
{
protected Collection $groups;
protected array $attributes;
public function __construct(Collection $groups)
{
$this->groups = $groups;
$this->attributes = HourRow::getAttributes();
}
public function view(): View
{
return view('excel.export', [
'attributes' => $this->attributes,
'groups' => $this->groups,
]);
}
/**
* @return string
*/
public function title(): string
{
return 'Uren';
}
public function columnFormats(): array
{
return [
'I' => NumberFormat::FORMAT_DATE_DDMMYYYY,
];
}
public function registerEvents(): array
{
return [
AfterSheet::class => function(AfterSheet $event) {
$event->sheet->freezePane('A2');
},
];
}
}