Here is other solution that might be helpful - as openpyxl function max_row and max_column takes into consideration also empty cells with styles applied I think that using pandas is better in that case:
import pandas as pd
def get_max_row_column(df, sheet_name):
max_row = 1
max_col = 1
for sh_name, sh_content in df.items():
if sh_name == sheet_name:
max_row = len(sh_content) + 1
max_col = len(sh_content.columns)
break
coordinates = {'max_row': max_row, 'max_col': max_col}
return coordinates
df = pd.read_excel('xls_path', sheet_name=None)
max_row = get_max_row_column(df, 'Test_sheet')['max_row']
max_col = get_max_row_column(df, 'Test_sheet')['max_col']
By providing sheet_name=None I create dictionary of all worksheets where key is sheet name and value sheet content (which is pandas DataFrame de facto).