Reputation: 61
in range (ws) below I have datetimes. I tried hours to print only early / late date but I couldn't. Like min() , max(), if else.. and etc. It has be very simple way I think, but dont know how. How to solve this headache?
from openpyxl import load_workbook
import datetime
wb = load_workbook(filename = 'Test.xlsx')
ws = wb.active
ws1 = ws['B3':'B7']
for i in ws1:
for cell in i:
print (cell.value)
Upvotes: 0
Views: 294
Reputation: 19527
You need to extract the values of the cells.
values = [row[0].value for row in ws['B3:B7']]
print(min(values))
print(max(values))
Upvotes: 2