Premlatha
Premlatha

Reputation: 1976

how to set page orientation(landscape or portrait) in phpspreadsheet

I want to set pagesetup in excel using phpspreadsheet. I found to do it using phpexcel from here. I do not know what to replace at PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT.

$sheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);

Thanks in advance.

Upvotes: 5

Views: 7945

Answers (2)

Alejandro De Castro
Alejandro De Castro

Reputation: 2257

Acording to the documentation, this is te correct way to set:

// for orientation
$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);

// paper size
$spreadsheet->getActiveSheet()->getPageSetup()->setPaperSize(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4);

Upvotes: 4

Premlatha
Premlatha

Reputation: 1976

I found the answer. I tried it after go through PageSetup.php in PHPSpreadsheet.

$sheet->getPageSetup()->setOrientation(PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_PORTRAIT);

Upvotes: 6

Related Questions