Closed lindymad closed 1 year ago
setPaperSize takes an integer argument, not a string. The following should work:
$sheet->getPageSetup()->setPaperSize(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER);
Unsurprisingly, that constant has a value of 1, which is what you said above that you were using as a workaround.
You can find the set of valid constants defined in the PageSetup
class
@oleibman - ah so this is a compatibility issue from a previous version (it worked with the string in 1.2.1, which I just upgraded from). I will change to use the constant. Thanks!
This is:
What is the expected behavior?
The paper size should be set to USLETTER and no error should be thrown
What is the current behavior?
An error is thrown with the message "Invalid page format: ". Note - If I change the code to
$sheet->getPageSetup()->setPaperSize(1);
then it worksWhat are the steps to reproduce?
What features do you think are causing the issue
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
PDF
Which versions of PhpSpreadsheet and PHP are affected?
I found the issue in PHPSpreadsheet 1.28.0 / PHP 7.4. It was working fine in PHPSpreadsheet 1.2.1 / PHP 7.4