I can convert date read from excel to a proper date using xldate_as_tuple function. Is there any function which can do the reverse i.e. convert proper date to float which is stored as date in excel ?
In the xlrd xldate.py module there are several functions, xldate_from_date_tuple()
, xldate_from_time_tuple()
and xldate_from_datetime_tuple()
, which convert datetime objects to Excel series dates.
Also, in the XlsxWriter utility.py module there is a function called datetime_to_excel_datetime()
which converts datetime objects for an Excel serial date.
All of these solutions take into account the epoch and the Excel 1900 leapyear bug.