I’m trying to use comtypes for Excel automation. I want to replace a Range
with a two-dimensional list or tuple. This seems to work with win32com, but
not with comtypes. Comtypes does not raise an exception, but it blanks out
the range with no message.



Below is a code sample to show what I’m trying to accomplish. I use a
generator expression for brevity, but any tuple of tuples, list of lists or
combination of the two doesn’t seem to work.



>>> from comtypes.client import CreateObject
>>> xl = CreateObject("Excel.application")
>>> xl.Workbooks.Add()
>>> sheet = xl.Workbooks[1].Sheets["Sheet1"]
# at this point, I manually typed into the range A1:B3
>>> sheet.Range("A1","B3").Value()
((u'AAA', 1.0), (u'BBB', 2.0), (u'CCC', 3.0))
>>> sheet.Range("A1","B3").Value[()] = [(x,y) for x,y in
zip('xyz',xrange(3))]


Any thoughts?

-Shawn
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users

Reply via email to