close

How to find the last row in a column using openpyxl normal workbook?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to find the last row in a column using openpyxl normal workbook in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to find the last row in a column using openpyxl normal workbook?

  1. find the last row in a column using openpyxl normal workbook?

    Since version openpyxl 2.4 you can also access individual rows and columns and use their length to answer the question.

  2. last row in a column using openpyxl normal workbook

    Since version openpyxl 2.4 you can also access individual rows and columns and use their length to answer the question.

Method 1

ws.max_row will give you the number of rows in a worksheet.

Since version openpyxl 2.4 you can also access individual rows and columns and use their length to answer the question.

len(ws['A'])

Though it’s worth noting that for data validation for a single column Excel uses 1:1048576.

Method 2

Find length of row and length of col.

Column:

column=sheet['A']
output tuple-->(A1,A2,A3........An)

len(column)
output length--> 18                    

for row length:

for i in sheet.iter_rows(max_row=0):

    print(len(i))

    break

This will give you length of header row where you put feature name . If you wan to get all rows length add max_row=len(column) and remove break.

Conclusion

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read