Problem assigning timevalue to Excel - COM

Mark Hammond mhammond at skippinet.com.au
Wed Jun 14 15:31:29 EDT 2000


In article <8i7pp7$1vl$1 at newstoo.ericsson.se>,
  "Bror Johansson" <bror.johansson at esavionics.se> wrote:
> I haven't found out what type and/or format to use when assigning a
value to
> a cell in MS Excel having a predefined time format like this:
> 1997-04-03  12:15:00

The formatting of a cell is completely seperate from setting its
value.  So you need 2 steps - first you set the cell to the "Time"
object, then you ask Excel to format the time.

Generally, you can convert to and from the Python time module's
concepts of time, and the PythonCOM time object - eg, when converting
the tine object to an int, the int is compatible with the time module,
and can be used with any functions that take a tick count.

Ditto the other way - generally you convert the time module object to
the standard time tuple used, and pass this to the Time constructor (as
found in the pywintypes and pythoncom modules).

For a working example, check out win32com\test\testMSOffice.py - there
we set a time value, read it back, and compare them.

Mark.


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list