Writing to Excel in Python 2.2

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dubana09
    New Member
    • Dec 2009
    • 1

    Writing to Excel in Python 2.2

    Hi all,
    I’m relatively new to python. I’m using a process simulation package which is stuck in the past unfortunately – it would not support any version older than python 2.2. This fairly frustrating as you can imagine.

    This means I cannot use pyExcelerator or xlwt to create spreadsheets and write to excel. Unlike reading (using xlrd), there doesn’t seem to be any package library out there for writing that is supported in python 2.2.
    I’m hoping someone would be kind enough to direct me to one. May be developers who have used python since the days of the 2.2 version might have something stored away somewhere!!!

    Your help is highly appreciated

    Satti
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Satti,

    You can write to an Excel file with win32com. This works in Python 2.3:
    Code:
    import datetime
    import win32com.client
    xlApp = win32com.client.Dispatch("Excel.Application")
    xlApp.Visible=0
    wb = xlApp.Workbooks.Open("Test.xls")
    t = wb.Worksheets(3).Range("A1", "B5").Value
    wb.Worksheets(3).Range("B1").Value = str(datetime.timedelta(t[0][0]))
    wb.Close(SaveChanges=1)
    xlApp.Quit()

    Comment

    • melissajean
      New Member
      • Aug 2010
      • 6

      #3
      you can also try importing the csv package. I'm not 100% sure if works on Python 2.2, but I think it does.

      Comment

      Working...