Getting Wrong row count while reading xlsx files using getHighestRow()

Topics: Developer Forum, Project Management Forum, User Forum
Sep 18, 2010 at 6:29 AM

Hi,

I am new to PHPExcel and PHP.

I am using wamp 2.0 in my local system, I have created a file to read an xlsx file, when I execute the page I get wrong row count. I have 10 rows but the page displays as 3 rows.

My code is given below

---------------------------------------------

require_once 'PHPExcel/Reader/Excel2007.php'
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load("xl_data/worksheet.xlsx");
$objPHPExcel->setActiveSheetIndex(0);
$objWorksheet = $objPHPExcel->getActiveSheet();

echo $highestRow = $objWorksheet->getHighestRow();

---------------------------------------------

My excel file (worksheet.xlsx) has 10 rows with values as 1,2,3,4,5,6,7,8,9 and 10 respectively

I expect the row count to be 10

But the variable $highestRow returns 3

Is there something wrong in my code ??

Pls help

- Praveen

 

Coordinator
Sep 18, 2010 at 10:49 AM

I'd need to know see the Excel workbook to be able to identify if there was any problem. Is it possible for you to upload it somewhere that I can access it?

Sep 18, 2010 at 11:37 AM

Hey Mark,

Thanks for your response !

My code is available at

1. Both xlsx and php file in rar format

-------------------------

http://bucsealumni.com/utilities/xl_readers/xl_readers/theCode.rar

 

2. My xlsx file

--------------

http://bucsealumni.com/utilities/xl_readers/xl_readers/xl_data/worksheet.xlsx.

 

3. My php file

-------------

http://bucsealumni.com/utilities/xl_readers/xl_readers/readworksheet.php

 

Thanks for your support

- Praveen

Sep 20, 2010 at 11:20 AM

Hey Mark,

I have solved the issue, there was an issue with my "php_zip" extension

thanks for your support.

- Praveen

Coordinator
Sep 21, 2010 at 12:32 PM
praveenkumarek wrote:

I have solved the issue, there was an issue with my "php_zip" extension

 Glad to hear that you've resolved this, because I hadn't been able to replicate the problem myself even with your code and workbook.