0

I'm getting attribute error while trying to get the row count in the excel sheet.I have used openpyxl library in python

This is python 3x version and openpyxl latest version used

import openpyxl from openpyxl import load_workbook wb=load_workbook("automation-book-example.xlsx")

get the sheet

ws=wb.get_sheet_by_name('Sheet1')

print(ws.get_highest_row())

Traceback (most recent call last): File "C:\Users\kamaraj\Desktop\python-excel\openpyxl\automation-book-example.py", line 9, in print(ws.get_highest_row()) AttributeError: 'Worksheet' object has no attribute 'get_highest_row'

Kamaraj
  • 63
  • 1
  • 8

1 Answers1

4

The get_highest_row() method has been deprecated, you can get the highest row or column by calling the max_row or max_column properties of the worksheet.

ws=wb.get_sheet_by_name('Sheet1')

print(ws.max_row)
idemello
  • 41
  • 1
  • while using library function,how to can i find that method is depreciated or not? – Kamaraj Jun 07 '19 at 04:16
  • This answer has some good techniques for it: https://stackoverflow.com/questions/7580532/how-to-check-whether-a-method-exists-in-python – idemello Jun 07 '19 at 19:54