create excel for6 controller

This commit is contained in:
2025-08-11 15:33:08 +03:30
parent 2c89c7e72c
commit aee17c20ed
21 changed files with 1380 additions and 11 deletions

View File

@@ -2,7 +2,40 @@
namespace App\Exports\SystemMessage;
class SupervisorCartable
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Collection;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\AfterSheet;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
class SupervisorCartableExcel implements FromView, WithEvents, ShouldAutoSize
{
public function __construct(private ?Collection $data){}
public function view(): View
{
return view('Reports.SystemMessage.SupervisorCartableReport', [
'data' => $this->data,
]);
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
$event->sheet->getDelegate()->setRightToLeft(true);
$event->sheet->getDelegate()->getStyle('A:U')->getFont()->setName('Arial');
$event->sheet->getDelegate()->getStyle('A:U')
->getAlignment()
->setHorizontal(Alignment::HORIZONTAL_CENTER);
$event->sheet->getDelegate()->getStyle('A:U')
->getAlignment()
->setVertical(Alignment::VERTICAL_CENTER);
}
];
}
}