You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Dennis, I hope you're doing well. I just wanted to let you know that I was able to landscape the PDF using the event as you suggested. Thank you for your help!
Here are the code I have used:
Sheet::listen(BeforeSheet::class, function ($sheet) {
$sheet->getDelegate()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
$sheet->getDelegate()->getStyle('1')->getFont()->setSize(8);
});
However, you can use the RegistersEventListeners trait to automatically register the event listeners. To do so, simply add the trait to your class and include this function within your class:
beforeSheet(BeforeSheet $event)
{
$event->sheet->getDelegate()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
}
or you can just add this one in your Page without trait
publicfunctionboot()
{
Sheet::listen(BeforeSheet::class, function ($sheet) {
$sheet->getDelegate()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
$sheet->getDelegate()->getStyle('1')->getFont()->setSize(8);
});
}
The text was updated successfully, but these errors were encountered:
From Discord:
The text was updated successfully, but these errors were encountered: