How can I find the last row of particular column?
i know that getHighestRow()
will give you the highest row of the sheet.
Is there a way to find highest row for specified column??
To be more specific
If you have two columns A and B
Column A has data in 5 rows and Column B has data in 7 rows.
I would like to get row 5 as my response, since it is the last entry under column A and would like to ignore rows 6 and 7
When I use getHighestRow method I would get row 7 as highest row.
Regards, Dheeraj
There is no built-in method to do this, you would need to write your own function to loop through the cells in that column and return the row number for the last cell.
Note that getHighestRow() and getHighestColumn() return the highest row and column in the spreadsheet, as long as they are referenced by something in the worksheet; but that could simply be an empty cell that contains style information.
Nobody has every actually requested this; but I have seen a couple of questions asking how to do it: so I may consider adding an optional argument to the getHighestDataRow() and getHighestDataColumn() methods for the next release.
EDIT
With effect from PHPExcel version 1.8.0, it is possible to pass a row number to the getHighestColumn()
or getHighestDataColumn()
, to return the highest column containing cell data in the specified row; or a column letter to the getHighestRow()
or getHighestDataRow()
methods to return the highest row number containing cell data in that column.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With