Cell as Date format with no value errors on read
Created originally on Bitbucket by stringfellow
See trace; first discovered by attempting to read a cell written by Excel with these properties.
#!python
In [1]: import openpyxl
In [2]: wb = openpyxl.workbook.Workbook()
In [3]: a1 = wb.active['A1']
In [4]: a1.value = None
In [5]: a1.style = openpyxl.styles.Style()
In [6]: a1.data_type = a1.TYPE_NUMERIC
In [7]: a1.number_format = 'dd-mm-yy'
In [8]: a1.value
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-8-7ddd53192eab> in <module>()
----> 1 a1.value
/Users/spike/Code/openpyxl/openpyxl/cell/cell.pyc in value(self)
347 value = self._value
348 if self.is_date():
--> 349 value = from_excel(value, self.base_date)
350 return value
351
/Users/spike/Code/openpyxl/openpyxl/compat/functools.pyc in wrapper(*args, **kwds)
120 stats[HITS] += 1
121 return result
--> 122 result = user_function(*args, **kwds)
123 with lock:
124 root, = nonlocal_root
/Users/spike/Code/openpyxl/openpyxl/date_time.pyc in from_excel(value, offset)
113 @lru_cache()
114 def from_excel(value, offset=CALENDAR_WINDOWS_1900):
--> 115 parts = list(jd2gcal(MJD_0, value + offset - MJD_0))
116 fractions = value - int(value)
117 diff = datetime.timedelta(days=fractions)
TypeError: coercing to Unicode: need string or buffer, float found
Attachments: no_date.xlsx