Uncaught exception 'Exception' with message 'Valid scale is between 10 and 400.' in Classes/PHPExcel/Worksheet/PageSetup.php:338

Topics: Developer Forum, User Forum
Jul 27, 2009 at 2:16 PM
Edited Jul 27, 2009 at 2:26 PM

I get that error when trying to convert a .xls file to .csv with the following code:

$objReader = PHPExcel_IOFactory::createReader('Excel5');
$objPHPExcel = $objReader->load('test.xls');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
$objWriter->save('test.csv');

Full stack trace:

#0 Classes/PHPExcel/Reader/Excel5.php(2319): PHPExcel_Worksheet_PageSetup->setScale(0)
#1 Classes/PHPExcel/Reader/Excel5.php(696): PHPExcel_Reader_Excel5->_readPageSetup()
#2 - PHPExcel_Reader_Excel5->load('test.xls')
#3 {main}
  thrown in Classes/PHPExcel/Worksheet/PageSetup.php on line 338


I'm pretty sure there is some junk data in the .xls file that is causing this
(especially considering that opening the file in OpenOffice Calc and saving
it again in the same format fixes the problem), however, I think such junk
data shouldn't cause a crash like this, as the PageSetup shouldn't be used
for anything in this case.

Of course, is this is better handled in my application I'm prepared to fix it there
instead.

And as the file that causes the error contains customer data I'm afraid I can't
post it here, but I could send it to a developer. (as I've done before)

And this is using latest changeset, 28241

Developer
Jul 27, 2009 at 6:20 PM

>> And as the file that causes the error contains customer data I'm afraid I can't
>> post it here, but I could send it to a developer. (as I've done before)


Yes, please. Can you send it to (erik at phpexcel dot net). Also, do you know which program was used to create the xls file?

Jul 28, 2009 at 8:32 AM

File sent.

Developer
Jul 28, 2009 at 10:57 PM

Thanks, work item created for this:

http://phpexcel.codeplex.com/WorkItem/View.aspx?WorkItemId=10363

It should be working with next source code release tomorrow:

http://phpexcel.codeplex.com/SourceControl/ListDownloadableCommits.aspx

Jul 29, 2009 at 8:22 AM

Indeed it did, using today's source code release it worked fine. Thanks!