Win32com and Excel

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike P

    Win32com and Excel

    Hi,

    I currently have an excel table (1 table each time) that has differing
    number of rows and differing number of columns each time, for another
    program i use (SPSS) to import the data i need to know the cell range
    of this data table.
    I.e what the last row of data is and the last column that has data in
    it.

    Does anyone have any code that does something similar? My guess is i
    have to do something like thefollowing to enable python to read xl?

    import win32com.client
    working_dir = '//c:/temp/'
    xl = win32com.client .Dispatch("Exce l.Application")
    xl.Visible = 1 #open MS Excel
    xl.Workbooks.Op en('%s/working_output. xls' % (working_dir))

    then code to find the cell ranges

    Any help here is much appreciated

    Mike
  • Ryan Ginstrom

    #2
    RE: Win32com and Excel

    On Behalf Of Mike P
    Does anyone have any code that does something similar? My
    guess is i have to do something like thefollowing to enable
    python to read xl?
    I think that what you want is UsedRange

    for row in sheet.UsedRange .Value:
    ...

    Regards,
    Ryan Ginstrom

    Comment

    Working...