Restore Export PDF button to the UI

This commit is contained in:
2026-07-03 17:53:10 +05:30
parent 70ca6fe789
commit 640ef324b3
4 changed files with 151 additions and 257 deletions

View File

@@ -5,8 +5,13 @@ namespace Modules\DailySalePaymentReportModule\Exports;
use Illuminate\Contracts\View\View;
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;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Fill;
class DailySalePaymentReportExport implements FromView, ShouldAutoSize
class DailySalePaymentReportExport implements FromView, ShouldAutoSize, WithEvents
{
protected $data;
@@ -19,4 +24,20 @@ class DailySalePaymentReportExport implements FromView, ShouldAutoSize
{
return view('dailysalepaymentreportmodule::export', $this->data);
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
$sheet = $event->sheet->getDelegate();
$highestColumn = $sheet->getHighestColumn();
$highestRow = $sheet->getHighestRow();
$dataRange = 'A1:' . $highestColumn . $highestRow;
// Set borders for everything
$sheet->getStyle($dataRange)->getBorders()->getAllBorders()->setBorderStyle(Border::BORDER_THIN);
$sheet->getStyle($dataRange)->getAlignment()->setVertical(Alignment::VERTICAL_TOP);
},
];
}
}