Python 3.5.2 , openpyxl v 2.4.1 ,get_highest_row() , AttributeError

7.9k Views Asked by At

I'm new to Python,while I'm facing a problem with opening an Excel file with openpyxl Module.I'm Running openpyxl V2.4.1 on Python 3.5.2 on Windows.Here is a small part of my Code.I'm getting the Following Error.

This is the Error I'm getting:

enter image description here

Please Help me to Solve this,finding a Way to get Maximum number of Rows and Columns in a Sheet.

If I have to change my openpyxl Module version,please describe!

Thanks in advance.

WorkBook = openpyxl.load_workbook("G:\\Python_Created\\DS.xlsx")
#I have a Sheet named "Original" in my Excell Workbook
Sheet = WorkBook.get_sheet_by_name("Original")
Sheet.get_highest_row()
2

There are 2 best solutions below

0
On BEST ANSWER

Check out enigmas answer

wb = load_workbook(path, use_iterators=True)
sheet = wb.worksheets[0]

row_count = sheet.max_row
column_count = sheet.max_column
0
On

I think that method is depreciated, In the newer version of openpyxl library Visit https://pypi.org/project/openpyxl/ you can use this method to get the Row Count and Column count

#to get the row count
sheet.max_row
#to get the column count
sheet.max_column