I noticed there is not a main entry point to your python script so I incorporated a more abstract version of your code. Besides that I do not understand why you passed in a sheet
to def Email_ID
when you instantiated one(sheet = wb.get_sheet_by_name(sheet)
) inside your function.
I am assuming you mean to get all emails from first column, if not a small change can be made to grab emails vertically.
Besides that, I have tested this code and it works on Mojave MacOS. This python script will get all values from first column dynamically:
from openpyxl import load_workbook
def main():
curr_sheet = get_sheet()
for i in range(1, curr_sheet.max_row + 1):
print(email_id(i, 1, curr_sheet))
# get email from each row based on parameters passed
def email_id(row_Num, cell_Num, sheet):
email = sheet.cell(row=row_Num, column=cell_Num).value
if email is not None:
return email
else:
return ''
# setup our sheet to be easily passed through various functions
def get_sheet():
wb = load_workbook('/Users/sudoxx2/Downloads/test_sheet.xlsx')
sheet = wb.active
return sheet
# main entry point to our python script(universal entry point in most python scripts)
if __name__ == "__main__":
main()
Please let me know if you have any questions.