Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Python & OpenOffice Spreadsheets

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


gh at ghaering

Nov 23, 2009, 2:49 AM

Post #1 of 11 (789 views)
Permalink
Python & OpenOffice Spreadsheets

Is there a *simple* way to read OpenOffice spreadsheets?

Bonus: write them, too?

I mean something like:

doc.cells[0][0] = "foo"
doc.save("xyz.ods")

>From a quick look, pyodf offers little more than just using a XML parser
directly.

-- Gerhard

--
http://mail.python.org/mailman/listinfo/python-list


paul.nospam at rudin

Nov 23, 2009, 3:12 AM

Post #2 of 11 (782 views)
Permalink
Re: Python & OpenOffice Spreadsheets [In reply to]

Gerhard Häring <gh [at] ghaering> writes:

> Is there a *simple* way to read OpenOffice spreadsheets?
>
> Bonus: write them, too?
>
> I mean something like:
>
> doc.cells[0][0] = "foo"
> doc.save("xyz.ods")
>
>>From a quick look, pyodf offers little more than just using a XML parser
> directly.


Depends on exactly what you mean by "simple" - but pyuno allows you to
read and write openoffice spreadsheets.
--
http://mail.python.org/mailman/listinfo/python-list


hackingkk at gmail

Nov 23, 2009, 3:25 AM

Post #3 of 11 (783 views)
Permalink
Re: Python & OpenOffice Spreadsheets [In reply to]

On Mon, 2009-11-23 at 11:12 +0000, Paul Rudin wrote:
> Gerhard Häring <gh [at] ghaering> writes:
>
> > Is there a *simple* way to read OpenOffice spreadsheets?
> >
> > Bonus: write them, too?
> >
> > I mean something like:
> >
> > doc.cells[0][0] = "foo"
> > doc.save("xyz.ods")
> >
> >>From a quick look, pyodf offers little more than just using a XML parser
> > directly.
>
>
> Depends on exactly what you mean by "simple" - but pyuno allows you to
> read and write openoffice spreadsheets.


Odfpy is a good module and is easy too.
http://kk.hipatia.net/public/gnukhata/gnukhata-client/ has a deb package
I built for ubuntu 9.04.
I can even provide you the distutils tarball off the list (because I
can't recall the url from I downloaded it, may be sourceforge ).
Happy hacking.
Krishnakant

--
http://mail.python.org/mailman/listinfo/python-list


chris at simplistix

Nov 23, 2009, 4:18 AM

Post #4 of 11 (783 views)
Permalink
Re: Python & OpenOffice Spreadsheets [In reply to]

Gerhard Häring wrote:
> Is there a *simple* way to read OpenOffice spreadsheets?

Ironically, if you don't mind working in .xls, which OpenOffice handles
just fine, you have xlrd and xlwt to do exactly what you're after:

http://www.python-excel.org/

cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


jfabiani at yolo

Nov 23, 2009, 11:01 AM

Post #5 of 11 (771 views)
Permalink
Re: Python & OpenOffice Spreadsheets [In reply to]

Krishnakant wrote:

> On Mon, 2009-11-23 at 11:12 +0000, Paul Rudin wrote:
>> Gerhard Häring <gh [at] ghaering> writes:
>>
>> > Is there a *simple* way to read OpenOffice spreadsheets?
>> >
>> > Bonus: write them, too?
>> >
>> > I mean something like:
>> >
>> > doc.cells[0][0] = "foo"
>> > doc.save("xyz.ods")
>> >
>> >>From a quick look, pyodf offers little more than just using a XML
>> >>parser
>> > directly.
>>
>>
>> Depends on exactly what you mean by "simple" - but pyuno allows you to
>> read and write openoffice spreadsheets.
>
>
> Odfpy is a good module and is easy too.
> http://kk.hipatia.net/public/gnukhata/gnukhata-client/ has a deb package
> I built for ubuntu 9.04.
> I can even provide you the distutils tarball off the list (because I
> can't recall the url from I downloaded it, may be sourceforge ).
> Happy hacking.
> Krishnakant

Would you including me in your response. I'd really like to find a py
module to allow simple use of openoffice.

Johnf
--
http://mail.python.org/mailman/listinfo/python-list


tjreedy at udel

Nov 23, 2009, 12:28 PM

Post #6 of 11 (769 views)
Permalink
Re: Python & OpenOffice Spreadsheets [In reply to]

Krishnakant wrote:
> On Mon, 2009-11-23 at 11:12 +0000, Paul Rudin wrote:
>> Gerhard Häring <gh [at] ghaering> writes:
>>
>>> Is there a *simple* way to read OpenOffice spreadsheets?
>>>
>>> Bonus: write them, too?
>>>
>>> I mean something like:
>>>
>>> doc.cells[0][0] = "foo"
>>> doc.save("xyz.ods")
>>>
>>> >From a quick look, pyodf offers little more than just using a XML parser
>>> directly.
>>
>> Depends on exactly what you mean by "simple" - but pyuno allows you to
>> read and write openoffice spreadsheets.
>
>
> Odfpy is a good module and is easy too.

Tarball at
http://pypi.python.org/pypi/odfpy/

Hello world example at
http://opendocumentfellowship.com/development/projects/odfpy

--
http://mail.python.org/mailman/listinfo/python-list


rt8396 at gmail

Nov 23, 2009, 4:48 PM

Post #7 of 11 (776 views)
Permalink
Re: Python & OpenOffice Spreadsheets [In reply to]

On Nov 23, 4:49 am, Gerhard Häring <g...@ghaering.de> wrote:
> Is there a *simple* way to read OpenOffice spreadsheets?
>
> Bonus: write them, too?
>
> I mean something like:
>
> doc.cells[0][0] = "foo"
> doc.save("xyz.ods")
>
> >From a quick look, pyodf offers little more than just using a XML parser


I find the syntax far to complicated than it should be. Here is an
example just to insert some text..

import uno

""" Here is the sequence of things the lines do:
1. Get the uno component context from the PyUNO runtime
2. Create the UnoUrlResolver
3. Get the central desktop object
4. Declare the ServiceManager
5. Get the central desktop object
6. Access the current writer document
7. Access the document's text property
8. Create a cursor
9. Insert the text into the document """

localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", localContext )
ctx = resolver.resolve
( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
smgr = ctx.ServiceManager
desktop = smgr.createInstanceWithContext
( "com.sun.star.frame.Desktop",ctx)
model = desktop.getCurrentComponent()
text = model.Text
cursor = text.createTextCursor()

text.insertString( cursor, "Hello World", 0 )

""" Do a nasty thing before exiting the python process. In case the
last call is a one-way call (e.g. see idl-spec of insertString),
it must be forced out of the remote-bridge caches before python
exits the process. Otherwise, the one-way call may or may not reach
the target object.
I do this here by calling a cheap synchronous call
(getPropertyValue)."""
ctx.ServiceManager

WHAT!?!?!??!

I don't mean to discredit these guys but the API should be re-thought,
and re-written! I don't care about component contexts, unoresolvers,
or little green aliens. I just want to insert 'Hello World' into cell
A3! Sheesh, There must be an easier way!
--
http://mail.python.org/mailman/listinfo/python-list


icanbob at gmail

Nov 25, 2009, 2:18 PM

Post #8 of 11 (745 views)
Permalink
Re: Python & OpenOffice Spreadsheets [In reply to]

On Nov 23, 5:49 am, Gerhard Häring <g...@ghaering.de> wrote:
> Is there a *simple* way to read OpenOffice spreadsheets?
>
> Bonus: write them, too?
>
> I mean something like:
>
> doc.cells[0][0] = "foo"
> doc.save("xyz.ods")
>
> >From a quick look, pyodf offers little more than just using a XML parser
>
> directly.
>
> -- Gerhard


OO Calc has an HTML file feature for auto updating fields in a
spreadsheet.

I hacked together something for a talk a few years ago:

http://www.icanprogram.com/hosug

(See Open Office Calc demo section)
While it isn't Python code it should be easy enough to convert to
Python.

bob
--
http://mail.python.org/mailman/listinfo/python-list


ldo at geek-central

Nov 27, 2009, 8:44 PM

Post #9 of 11 (716 views)
Permalink
Re: Python & OpenOffice Spreadsheets [In reply to]

In message <486869af-d89f-4261-b4c2-
f45af5d3bb93 [at] e7g2000vbi>, r wrote:

> I find the syntax far to[o] complicated than it should be.

That’s because it was originally written for Java programmers.

--
http://mail.python.org/mailman/listinfo/python-list


rt8396 at gmail

Nov 27, 2009, 9:33 PM

Post #10 of 11 (715 views)
Permalink
Re: Python & OpenOffice Spreadsheets [In reply to]

On Nov 27, 10:44 pm, Lawrence D'Oliveiro <l...@geek-
central.gen.new_zealand> wrote:
> In message <486869af-d89f-4261-b4c2-
>
> f45af5d3b...@e7g2000vbi.googlegroups.com>, r wrote:
> > I find the syntax far to[o] complicated than it should be.
>
> That’s because it was originally written for Java programmers.

Well that explains the high level of asininity alright! ;-)
--
http://mail.python.org/mailman/listinfo/python-list


paul.nospam at rudin

Nov 28, 2009, 2:14 AM

Post #11 of 11 (714 views)
Permalink
Re: Python & OpenOffice Spreadsheets [In reply to]

r <rt8396 [at] gmail> writes:

> On Nov 23, 4:49 am, Gerhard Häring <g...@ghaering.de> wrote:
>> Is there a *simple* way to read OpenOffice spreadsheets?
>>
>> Bonus: write them, too?
>>
>> I mean something like:
>>
>> doc.cells[0][0] = "foo"
>> doc.save("xyz.ods")
>>
>> >From a quick look, pyodf offers little more than just using a XML parser
>
>
> I find the syntax far to complicated than it should be. Here is an
> example just to insert some text..

[employing weapons of mass snippage]

It's true that it's a hassle, but the boiler plate stuff can be stuck in
a function and then forgotton about really.


--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.