2

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()
  • 3
    I think there is no such attribute in the Latest Version of `openpyxl`.Using `SheetObj.max_row` and `SheetObj.max_column` will serve the same purpose.They will Return the Highest Number of Rows and Columns respectively. – R.S.S.H KRISHNA Jan 02 '17 at 16:56

2 Answers2

7

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
Ken Fallon
  • 86
  • 1
  • 2
1

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
Kamaraj
  • 63
  • 1
  • 8