Reader->load error getHighestRow() on a non-object

Sep 9, 2009 at 4:43 AM


/** PHPExcel */
require_once '../phpexcel1.7.0/Classes/PHPExcel.php';

/** PHPExcel_IOFactory */
require_once '../phpexcel1.7.0/Classes/PHPExcel/IOFactory.php';

//create reader
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
//load spreadsheet
$objPHPExcel = $objReader->load("C:/data/export.xlsx");   

//define source workbook worksheet
$objWorksheet = $objPHPExcel->getActiveSheet();

$highestRow = $objWorksheet->getHighestRow(); // Fatal error: Call to a member function getHighestRow() on a non-object in this line

$highestColumn = $objWorksheet->getHighestColumn(); // e.g 'F'
$highestColumnIndex = 2 ;
for ($row = 2; $row <= $highestRow; ++$row) {
    for ($col = 0; $col <= $highestColumnIndex; ++$col) {
        $value = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
        echo $objWorksheet->getCellByColumnAndRow($col, $row)->getValue();


Sep 9, 2009 at 4:50 AM

That's a strange error. I cannot see what is causing this.

Can you try to add the following lines at this at the beginning of you script, maybe you will see some more errors?

ini_set('display_errors', '1');

Sep 9, 2009 at 1:25 PM

Can you upload your file: C:/data/export.xlsx somewhere so we can test?

Or you can send it to me by email: (erik at phpexcel dot net)

Sep 11, 2009 at 12:43 AM

Thanks koyama 

My misstake on path load("C:/data/export.xlsx");

little problem as did not read out as regDate(int 11) from mysql

sample regDate = 1237080859 (just read it)

Sep 24, 2012 at 11:06 PM


I got this error too, in my case the file is on a linux pc.

Where is the problem?

I use the newest versin 1.7.7


Many thanks


Sep 25, 2012 at 12:28 PM


could not anyone help me?

I need urgent help to solve this issue.


Many thanks


Sep 25, 2012 at 12:33 PM

Try using the latest github develop branch code, it includes a fix for a bug that sometimes resulted in this error

Sep 25, 2012 at 1:13 PM


you mean the complete code?

Or is a part of the branch enough?


Many thanks


Sep 25, 2012 at 1:19 PM

I think the fix for the "Call to a member function getHighestRow() on a non-object in this line" is purely in Worksheet.php, but can't recall for certain; and there may be other changes that break if you pulled just that file. It's eaier if you pull the whole as it shoul dbe live as the 1.7.8 release by the weekend.