473,511 Members | 17,017 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jun 12 '07 #1
3 2231
On Jun 12, 11:01 pm, "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.
xlwt is a fork of pyExcelerator that I'm maintaining. It works with
Python 2.3 and later.

https://secure.simplistix.co.uk/svn/xlwt/trunk

Jun 12 '07 #2
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

Jun 12 '07 #3
On Jun 12, 8:38 am, kyoso...@gmail.com wrote:
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
Oops...forgot that to mention that I import the sleep function from
the time module in the above code. Sorry about that.

Mike

Jun 12 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
35485
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
4
20949
by: federico | last post by:
When I close an excel application opened from a python program with .Close() methood , in tasks manager is still present 'excel.exe' process and if I open manually an excel applicaion I have a...
5
1992
by: Bram Stolk | last post by:
pyHello, Google helped me find a nice package to interface python with MS Excel. "win32all", or sometimes called by the name "pywin32". http://starship.python.net/crew/mhammond/ However,...
3
3215
by: ian castleden | last post by:
From time to time I see requests for some sort of python MS Excel interface/software. I have written just such software 100% python (works with Jython too! at least it did a year ago). It was...
3
2061
by: Gerry Blais | last post by:
Newbie questions: Suppose abc.xls has sheets a, b, c. How can I find, in Python, the sheet names? Given a sheet name, how can I export the sheet as a csv file? Finally, how can I, in...
1
3690
by: koia | last post by:
Hi, I have a problem with adding attributes to a Line in an Excel drawing using the Python win32com interface. From recording in Excel I get the Macro: Sub Makro1()...
4
5822
by: Marco Aschwanden | last post by:
Hi I would like to 1. import an existing Excel-sheet (a template) 2. and add some data to it 3. and save it under a different name afterwards. To me it seems, that pyExcelerator does not...
3
3984
by: dan_roman | last post by:
Hi, I developed a script with a nice interface in Tkinter that allows me to edit some formulas and to generate an Excel worksheet with VBA macros within it. The script runs perfectlly in Office...
3
5349
by: Podi | last post by:
As far as I know, there is pyXLWriter for writing and xlrd for reading. Is there such thing so that one can open an Excel file into memory and read/update any sheet/cell on the fly. One analogy to...
20
3527
by: Marin Brkic | last post by:
Hello all, please, let me apologize in advance. English is not my first language (not even my second one), so excuse any errors with which I'm about to embarass myself in front of the general...
0
7242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7138
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7355
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7423
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7510
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5066
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.