Formatting Excel cells with PythonCOM

Mark Hammond mhammond at
Thu Apr 6 19:45:01 EDT 2000

This code is from the win32com test suite (in

 # test dates out with Excel
 xl.Cells(5,1).Value = "Excel time"
 xl.Cells(5,2).Formula = "=Now()"

 import time
 xl.Cells(6,1).Value = "Python time"
 xl.Cells(6,2).Value = pythoncom.MakeTime(time.time())
 xl.Cells(6,2).NumberFormat = "d/mm/yy h:mm"

"Scott" <sbarron at> wrote in message
news:38ECAF9D.ECA74709 at
> Hi,
> I am looking for information regarding how to set the Date/Time
> for Excel cells.  When I enter my dates/times I use the
DateTime module
> and the COMDate member of my objects.  When I open Excel it
> them as ###### until I manually set the date/time format.  How
can I do
> this from within my Python program?
> Thanks,
> Scott

More information about the Python-list mailing list