473,804 Members | 3,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python in a spreadsheet

Is it possible to call a Python function from Calc (the Open Office
spreadsheet) or Microsoft Excel? Are their web sites or books
describing how to do this?

I would prefer not to write any more VBA :).
Jul 18 '05 #1
7 2353
On Mon, 2003-12-15 at 21:18, be*******@aol.c om wrote:
Is it possible to call a Python function from Calc (the Open Office
spreadsheet) or Microsoft Excel? Are their web sites or books
describing how to do this?

I would prefer not to write any more VBA :).


Yes to both I believe... the first with the python openoffice bridge
Python-UNO

google for 'python openoffice' scores about 115000 hits

The second would I guess be do-able with the win32 extensions.....

google 'win32 extensions python' about 34000 hits

Happy reading...
Martin.


--
Martin Franklin <mf********@gat wick.westerngec o.slb.com>
Jul 18 '05 #2
Hi !

I do it, from Excel, with an Python-COM-server (thanks Mark Hammond) and the
aspect "dynamic" of the Python language.
Michel Claveau

Jul 18 '05 #3
be*******@aol.c om writes:
Is it possible to call a Python function from Calc (the Open Office
spreadsheet) or Microsoft Excel? Are their web sites or books
describing how to do this?


You could check out the latest version of StarOffice from Sun (version
7, I believe) -- apparently it has Python scripting support built-in.

I found that pretty interesting... Isn't Sun committed to something
called Joe or Java or something like that?

Nick

--
# sigmask || 0.2 || 20030107 || public domain || feed this to a python
print reduce(lambda x,y:x+chr(ord(y )-1),' Ojdl!Wbshjti!=o bwAcboefstobudi/psh?')
Jul 18 '05 #4
Am Mon, 15 Dec 2003 13:18:21 -0800 schrieb beliavsk:
Is it possible to call a Python function from Calc (the Open Office
spreadsheet) or Microsoft Excel? Are their web sites or books
describing how to do this?

I would prefer not to write any more VBA :).


I once posted a way to batch convert
files into a different format with pyuno.
Maybe this helps you
http://groups.google.com/gr*********...as-guettler.de

Depending on your problem, I would suggest to use
XML instead. I think it is more stable to export
the office file to XML, process it with your script,
and import it again. The remote procedure call solutions
(COM, pyUNO) don't scale well.

thomas

Jul 18 '05 #5
Thomas Guettler <gu*****@thom as-guettler.de> wrote:
Depending on your problem, I would suggest to use
XML instead. I think it is more stable to export
the office file to XML, process it with your script,
and import it again. The remote procedure call solutions
(COM, pyUNO) don't scale well.


Note that the OpenOffice.org native format (sx? files) are nothing but
zipped XML files:

[kahanpaa@nosuch address ~/diptera]$ unzip -l brachycera.sxc
Archive: brachycera.sxc
Length Date Time Name
-------- ---- ---- ----
28 12-09-03 17:37 mimetype
281295 12-09-03 17:37 content.xml
29859 12-09-03 17:37 styles.xml
1007 12-09-03 17:37 meta.xml
8779 12-09-03 17:37 settings.xml
750 12-09-03 17:37 META-INF/manifest.xml
-------- -------
321718 6 files

You could manipulate them directly using Python's XML facilities.

Jere
--
Lord, make my words as sweet as honey, for one day I may have to eat them
- Daryl Benson
Jul 18 '05 #6
"Thomas Guettler" <gu*****@thom as-guettler.de> writes:
Am Mon, 15 Dec 2003 13:18:21 -0800 schrieb beliavsk: [...] Depending on your problem, I would suggest to use
XML instead. [...] and import it again. The remote procedure call solutions
(COM, pyUNO) don't scale well.


Really? What problems did you have?
John
Jul 18 '05 #7
Nick Vargish <na*******@band ersnatch.org> writes:
be*******@aol.c om writes:
Is it possible to call a Python function from Calc (the Open Office
spreadsheet) or Microsoft Excel? Are their web sites or books
describing how to do this?


You could check out the latest version of StarOffice from Sun (version
7, I believe) -- apparently it has Python scripting support built-in.

I found that pretty interesting... Isn't Sun committed to something
called Joe or Java or something like that?


Yeah, but that's for the "enterprise technologists" -- I could think
of another word for them, though <wink>.
John
Jul 18 '05 #8

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

Similar topics

13
35568
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 and extract information from specific worksheets and cells. I'm not really sure how to get started with this process. I ran the COM Makepy utility from my PythonWin (IDE from ActiveSTate),
226
12735
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> d1 = {'a':1} >>> d2 = {'b':2} >>> d3 = {'c':3}
2
2119
by: quadric | last post by:
Hi, I have an application that requires that Python initiate and mediate a live and iterative conversation between an external application (in which Python is embedded) and an external Excel spreadsheet. Python will have to pass info to the spreadsheet, spreadsheet will make calculations, Python will obtain results and pass back to application, application will evaluate results of spreadsheet calculations and create new set of data and
6
3587
by: Wolfgang Keller | last post by:
Hello, I'm looking for a spreadsheet application (MacOS X prefered, but Windows, Linux ar available as well) with support for Python scripting (third-party "plug-ins" are ok) and a database interface. Applications that I know of (that they exist) are: MS Excel Quattro
267
10869
by: Xah Lee | last post by:
Python, Lambda, and Guido van Rossum Xah Lee, 2006-05-05 In this post, i'd like to deconstruct one of Guido's recent blog about lambda in Python. In Guido's blog written in 2006-02-10 at http://www.artima.com/weblogs/viewpost.jsp?thread=147358
4
1078
by: cmoller | last post by:
Hi, I am new to Python and the use of discussion groups. Is there a FAQ for basic information so certain questions are not repeated? I am NOT an experienced programmer, but have decided to write a data logger for sensors sending data via an internal ethernet work to machines running OS X (Intel). The program should store data and allow real time plotting. It does not need a beautiful GUI, but I may want to share the program with...
162
10324
by: Sh4wn | last post by:
Hi, first, python is one of my fav languages, and i'll definitely keep developing with it. But, there's 1 one thing what I -really- miss: data hiding. I know member vars are private when you prefix them with 2 underscores, but I hate prefixing my vars, I'd rather add a keyword before it. Python advertises himself as a full OOP language, but why does it miss one of the basic principles of OOP? Will it ever be added to python?
0
251
by: Gary Herron | last post by:
Greg Lindstrom wrote: Here's a snippet of code I use to open a spreadsheet (given as a file path name), and compute and return the list of sheets it contains. It connects to an existing OpenOffice if possible, otherwise it starts OpenOffice and waits for it to accept a connection. def OpenSS(path):
0
10586
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10338
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10082
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5525
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.