python - ValueError: Cannot convert <PyTime:9/11/2017 1:35:02 AM> to Excel -


i getting error while running below code

current_time=mailitem.receivedtime ws.cell(row=1, column=1).value = current_time 

error running code:

file "c:\python27\lib\site-packages\openpyxl\cell\cell.py", line 294, in value     self._bind_value(value)   file "c:\python27\lib\site-packages\openpyxl\cell\cell.py", line 201, in _bind_value     raise valueerror("cannot convert {0!r} excel".format(value)) valueerror: cannot convert <pytime:9/11/2017 1:35:02 am> excel 

it looks should manually convert pytime string or python date/time type. use

time.ctime(int(current_time)) or

time.strftime("%#c", time.localtime(int(current_time))).

see http://docs.activestate.com/activepython/2.4/pywin32/pytime.html


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -