Closed J1Duran closed 9 years ago
did you try the orientation setting?
$sheet->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)
Class PHPExcel_Worksheet_PageSetup' not found. I need to include a something?
If you have a namespaced class, you need to import it:
<?php
namespace YourNamespace;
use PHPExcel_Worksheet_PageSetup;
class YourClass {
}
Thank you. Any idea that does not exceed the size of the page?
Is bigger paper size an option?
How I do this?
$sheet->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3)
and use one of the constants in PHPExcel_Worksheet_PageSetup listed here: http://www.osakac.ac.jp/labs/koeda/tmp/phpexcel/Documentation/API/PHPExcel_Worksheet/PHPExcel_Worksheet_PageSetup.html
Thanks man.
Hi @patrickbrouwers,
How the same could be implemented in Laravel Excel Nova please? Where to put it please? Here is my code just not sure what public function to overwrite to get it across.
<?php
namespace App\Nova\Actions;
use Illuminate\Bus\Queueable;
use Laravel\Nova\Actions\Action;
use Illuminate\Support\Collection;
use Laravel\Nova\Fields\ActionFields;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
class ExportToPdf extends DownloadExcel implements ShouldAutoSize
{
(PageSetup::ORIENTATION_LANDSCAPE);
(PageSetup::PAPERSIZE_A4);
}
@aurawindsurfing
You can add custom concerns to your export: https://laravel-excel.maatwebsite.nl/3.1/exports/extending.html . In there you can call the native page setup methods on the delegate.
class ExportToPdf extends DownloadExcel implements ShouldAutoSize, \Maatwebsite\Excel\Concerns\WithEvents
{
/**
* @return array
*/
public function registerEvents(): array
{
return [
AfterSheet::class => function(AfterSheet $event) {
$sheet->getDelegate()->getPageSetup()->setOrientation($PageSetup::ORIENTATION_LANDSCAPE);
},
];
}
}
Then
Thanks!
Below code work for me,
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
$event->sheet->getDelegate()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
},
];
}
but i want paper size up to content is, can anyone help me out.
@riteshkhatri did you find the way how to make paper size up to content ?
Hello I have a question, How do I export horizontal PDF sheet? My table exceeds the size of the page.