Q:

PHPExcel - reads past last row

I'm somewhat perplexed by the behaviour of PHPExcel with some files I have.
The files contain approx. 3000 rows of data, but according to PHPExcel, the last row used is 65535. I tried and cut a few lines from the file and pasted them into a fresh file, to no avail. It doesn't matter whether it is Excel5 or Excel2007 format, always the same result.
Any ideas to find the error here?
CODE:
    $cr=$xls->getActiveSheet()->getHighestRow();
    $cn=PHPExcel_Cell::columnIndexFromString($xls->getActiveSheet()->getHighestColum‌​n()); 
    for ($z=2; $z<=$cr; $z++) { 
        $class=($z%2)?"odd":"even"; 
?> 
    <tr class="<?php echo $class; ?>"> 
    <?php for ($s=0; $s<$cn; $s++) { 
        $tmp=$xls->getActiveSheet()->getCellByColumnAndRow($s,$z)->getValue();?> 
        <td><?php echo $tmp; ?></td> 
    <?php } ?> </tr> 
<?php } ?>

A:

All it takes is a blank cell, and the last col/row can be a lot higher than you expect. Even print layout or styles can falsify the stored highest values. Open the file in MS Excel and press Ctrl-End, and it will take you to the last cell that Excel recognises.
In addition to getHighestRow() and getHighestColum() there's also a (slower) getHighestDataRow() and getHighestDataColumn() method that identify the highest row and column that actually contain cell data.

