On Jun 12, 8:01 am, "Hamilton, William " <wham...@entergy.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.Add()
sh = ss.ActiveSheet
xl.Visible = True
sleep(1)
sh.Cells(1,1).Value = 'Python-to-%s Demo' % app
sleep(1)
for i in RANGE:
sh.Cells(i,1).Value = '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