Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPExcel: How to Set an a Sheet's Paper Size with a User-Defined Paper Size?

Tags:

php

phpexcel

By using

$objPHPExcel->getActiveSheet() ->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4); we can set a sheet's page size, but how do you supply a custom Paper Size for this? I want to set it to 8.5' x 13.0', Letter is 8.5 x 11.0 while Legal is 8.5 x 14.0

like image 665
javiniar.leonard Avatar asked Oct 26 '25 06:10

javiniar.leonard


1 Answers

Check the source code for the library you're using at https://github.com/PHPOffice/PHPExcel/blob/1.8/Classes/PHPExcel/Worksheet/PageSetup.php#L35-L100

Line of interest is this one in the comments.

* 14 = Folio paper (8.5 in. by 13 in.)

Which you can use:

$objPHPExcel->getActiveSheet()->
getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_FOLIO);

It doesn't seem like you can set custom sizes though, only the predefined ones.

like image 123
Kalkran Avatar answered Oct 28 '25 19:10

Kalkran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!