Excel file interface for Python 2.3?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hamilton, William

    #1

    Excel file interface for Python 2.3?

    I'm in need of a module that will let me create Excel workbooks from within
    Python. Something like PyExcelerator, but it needs to work with Python 2.3.
    (A third-party limitation that I have no control over.) Can anyone point me
    to what I need? All my searches keep leading back to PyExcelerator.

    --
    -Bill Hamilton


  • John Machin

    #2
    Re: Excel file interface for Python 2.3?

    On Jun 12, 11:01 pm, "Hamilton, William " <wham...@enterg y.comwrote:
    I'm in need of a module that will let me create Excel workbooks from within
    Python. Something like PyExcelerator, but it needs to work with Python 2.3.
    (A third-party limitation that I have no control over.) Can anyone point me
    to what I need? All my searches keep leading back to PyExcelerator.
    >
    xlwt is a fork of pyExcelerator that I'm maintaining. It works with
    Python 2.3 and later.





    Comment

    • kyosohma@gmail.com

      #3
      Re: Excel file interface for Python 2.3?

      On Jun 12, 8:01 am, "Hamilton, William " <wham...@enterg y.comwrote:
      I'm in need of a module that will let me create Excel workbooks from within
      Python. Something like PyExcelerator, but it needs to work with Python 2.3.
      (A third-party limitation that I have no control over.) Can anyone point me
      to what I need? All my searches keep leading back to PyExcelerator.
      >
      --
      -Bill Hamilton
      You can also use COM if you're on Windows, via PyWin32. Hammond's book
      talks about it a little here: http://www.oreilly.com/catalog/pytho...pter/ch12.html

      I also saw some information about this in Core Python Programming by
      Chun.

      Example code follows:

      <code>

      import win32com.client as win32
      def excel():
      app = 'Excel'
      xl = win32.gencache. EnsureDispatch( '%s.Application ' % app)
      ss = xl.Workbooks.Ad d()
      sh = ss.ActiveSheet
      xl.Visible = True
      sleep(1)

      sh.Cells(1,1).V alue = 'Python-to-%s Demo' % app
      sleep(1)
      for i in RANGE:
      sh.Cells(i,1).V alue = 'Line %d' % i
      sleep(1)
      sh.Cells(i+2,1) .Value = "Th-th-th-that's all folks!"


      ss.Close(False)
      xl.Application. Quit()

      </code>

      Admittedly, COM is kind of confusing. But it's there if you need it.

      Mike

      Comment

      • kyosohma@gmail.com

        #4
        Re: Excel file interface for Python 2.3?

        On Jun 12, 8:38 am, kyoso...@gmail. com wrote:
        On Jun 12, 8:01 am, "Hamilton, William " <wham...@enterg y.comwrote:
        >
        I'm in need of a module that will let me create Excel workbooks from within
        Python. Something like PyExcelerator, but it needs to work with Python 2.3.
        (A third-party limitation that I have no control over.) Can anyone point me
        to what I need? All my searches keep leading back to PyExcelerator.
        >
        --
        -Bill Hamilton
        >
        You can also use COM if you're on Windows, via PyWin32. Hammond's book
        talks about it a little here:http://www.oreilly.com/catalog/pytho...pter/ch12.html
        >
        I also saw some information about this in Core Python Programming by
        Chun.
        >
        Example code follows:
        >
        <code>
        >
        import win32com.client as win32
        def excel():
        app = 'Excel'
        xl = win32.gencache. EnsureDispatch( '%s.Application ' % app)
        ss = xl.Workbooks.Ad d()
        sh = ss.ActiveSheet
        xl.Visible = True
        sleep(1)
        >
        sh.Cells(1,1).V alue = 'Python-to-%s Demo' % app
        sleep(1)
        for i in RANGE:
        sh.Cells(i,1).V alue = 'Line %d' % i
        sleep(1)
        sh.Cells(i+2,1) .Value = "Th-th-th-that's all folks!"
        >
        ss.Close(False)
        xl.Application. Quit()
        >
        </code>
        >
        Admittedly, COM is kind of confusing. But it's there if you need it.
        >
        Mike
        Oops...forgot that to mention that I import the sleep function from
        the time module in the above code. Sorry about that.

        Mike

        Comment

        Working...