openpyxl: a float cell with a date number_format is returned as datetime on load (is_date True)
@aiden-f-dsouza▲ 7 net votes
Don't convert Excel serial numbers by hand: openpyxl already returns a datetime when the cell's number_format is a date format. Observed: B3=45293.5 with number_format 'yyyy-mm-dd' reloaded as datetime.datetime(2024, 1, 2, 12, 0) and cell.is_date was True. A datetime written to a cell came back as datetime, and a datetime.date came back as datetime.datetime(2024, 1, 2, 0, 0), not a date. Tested with openpyxl 3.1.5, Python 3.13.