reading xlsx file getting: Valid scale is between 10 and 400

Jan 28, 2010 at 3:07 PM

Hello all,

I am using: PHP Version 5.2.6-3ubuntu4.5

PHP extension php_zip is enabled

I am using:  2010/01/11 (v1.7.2)

Fatal error: Uncaught exception 'Exception' with message 'Valid scale is between 10 and 400.' in /home/brian/www/Classes/PHPExcel/Worksheet/SheetView.php:115 Stack trace: #0 /home/brian/www/Classes/PHPExcel/Reader/Excel2007.php(552): PHPExcel_Worksheet_SheetView->setZoomScaleNormal(535) #1 /home/brian/www/XLSX/index.php(44): PHPExcel_Reader_Excel2007->load('/home/brian/www...') #2 {main} thrown in /home/brian/www/Classes/PHPExcel/Worksheet/SheetView.php on line 115

 

I have looked in the documentation but I only found related things to writing to an excel 2007 file But I only want to read from it.

Here is my code:

$excelReader = PHPExcel_IOFactory::createReader('Excel2007');
$excelReader->setReadDataOnly(true);
$excel = $excelReader->load($target); //and load the document


for ($i = 2; $i < 5; $i++) {

print($excel->getActiveSheet()->getCell('A' . $i)->getValue());
print("-->");
print($excel->getActiveSheet()->getCell('F' . $i)->getValue());
print("-->");
print($excel->getActiveSheet()->getCell('G' . $i)->getValue());
print("-->");
print($excel->getActiveSheet()->getCell('D' . $i)->getValue());

print("<br>");
}

I have changed in the php script: /home/brian/www/Classes/PHPExcel/Reader/Excel2007.php

if (isset($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])) {
$docSheet->getSheetView()->setZoomScaleNormal(399);
// intval($xmlSheet->sheetViews->sheetView['zoomScaleNormal']);
}

And it is working now but I am sure that this is not the correct way to do it.

Thanks in advance,

PolderBoy

Developer
Jan 30, 2010 at 9:49 PM

Thanks for your report. The correct way to fix this is to allow non-standard scales outside the range 10-400.

Work item created:

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

Download latest source code tomorrow:

http://phpexcel.codeplex.com/SourceControl/list/changesets