Formatting Excel cells with PythonCOM

Mark Hammond mhammond at skippinet.com.au
Fri Apr 7 01:45:01 CEST 2000


This code is from the win32com test suite (in testMSOffice.py)

 # 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"
 xl.Columns("A:B").EntireColumn.AutoFit()


"Scott" <sbarron at ansic.net> wrote in message
news:38ECAF9D.ECA74709 at ansic.net...
> Hi,
>
> I am looking for information regarding how to set the Date/Time
format
> 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
displays
> 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