fix and update v2 for operator
This commit is contained in:
70
app/Exports/V3/RoadObservation/OperatorCartableReport.php
Normal file
70
app/Exports/V3/RoadObservation/OperatorCartableReport.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\RoadObservation;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
|
||||
|
||||
class OperatorCartableReport implements FromView, ShouldAutoSize, WithEvents, WithDrawings
|
||||
{
|
||||
public function __construct(private ?Collection $data){}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
return view ("test", [
|
||||
'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);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings(): array
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('q1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user