Read / Write OpenOffice SpreadSheet ?

Discussion in 'Python' started by Torsten Mohr, Dec 17, 2010.

  1. Torsten Mohr

    Torsten Mohr Guest

    Hi,

    i search for a possibility to access OpenOffoce SpreadSheets from Python
    with a reasonably new version of Python.

    Can anybody point me to a package that can do this?


    Best regards,
    Torsten.
     
    Torsten Mohr, Dec 17, 2010
    #1
    1. Advertising

  2. Torsten Mohr

    Tim Harig Guest

    On 2010-12-17, Torsten Mohr <> wrote:
    > i search for a possibility to access OpenOffoce SpreadSheets from Python
    > with a reasonably new version of Python.
    >
    > Can anybody point me to a package that can do this?


    There is no package needed to read or write the new open document files.
    The files are merely a jar archive containing XML files. You can open
    and update them using jar as a subprocess and manipulate the XML files
    using your favorite XML libraries DOM/SAX/XPath/Etree/etc.

    If that doesn't suit you, you can manipulate them using Oo_Org through its
    UNO interface; but, I find that much more involved then simply accessing
    the files directly.
     
    Tim Harig, Dec 17, 2010
    #2
    1. Advertising

  3. Torsten Mohr

    joymanchen Guest

    "Torsten Mohr" å†™å…¥æ¶ˆæ¯ news:ieed6o$iqd$...

    Hi,

    i search for a possibility to access OpenOffoce SpreadSheets from Python
    with a reasonably new version of Python.

    Can anybody point me to a package that can do this?


    Best regards,
    Torsten.


    --- news://freenews.netfront.net/ - complaints: ---
     
    joymanchen, Dec 17, 2010
    #3
  4. Torsten Mohr

    Torsten Mohr Guest

    Hello,

    > There is no package needed to read or write the new open document files.
    > The files are merely a jar archive containing XML files. You can open
    > and update them using jar as a subprocess and manipulate the XML files
    > using your favorite XML libraries DOM/SAX/XPath/Etree/etc.


    thanks for your hint. I was aware of that, OO files are a bunch of zipped
    XML files. But, i searh for something more comfortable/highlevel that lets
    me just do things like doc.Cell(1, 3) = 'abc' or so.

    > If that doesn't suit you, you can manipulate them using Oo_Org through its
    > UNO interface; but, I find that much more involved then simply accessing
    > the files directly.


    Thanks, i read about it but as i understood it, UNO needs Python 2.3.x and
    i'd like to base on something actual.


    Best regards,
    Torsten.
     
    Torsten Mohr, Dec 17, 2010
    #4
  5. Torsten Mohr, 17.12.2010 02:07:
    > i search for a possibility to access OpenOffoce SpreadSheets from Python
    > with a reasonably new version of Python.
    >
    > Can anybody point me to a package that can do this?


    Have you looked through the relevant PyPI packages?

    http://pypi.python.org/pypi?:action=search&term=openoffice

    Stefan
     
    Stefan Behnel, Dec 17, 2010
    #5
  6. PyUNO [Was: Read / Write OpenOffice SpreadSheet ?]

    On Fri, 2010-12-17 at 10:19 +0100, Torsten Mohr wrote:
    > Thanks, i read about it but as i understood it, UNO needs Python 2.3.x and
    > i'd like to base on something actual.


    I do not *believe* this is true.

    <http://pypi.python.org/pypi/cloudooo/1.0.9> for instance is Python 2.6
    and uses PyUNO.

    I would strongly recommend against floundering about in OOo's very
    complex XML files - it is trivially easy to render a document unusable.
     
    Adam Tauno Williams, Dec 17, 2010
    #6
  7. Re: PyUNO [Was: Read / Write OpenOffice SpreadSheet ?]

    Adam Tauno Williams, 17.12.2010 17:02:
    > On Fri, 2010-12-17 at 10:19 +0100, Torsten Mohr wrote:
    >> Thanks, i read about it but as i understood it, UNO needs Python 2.3.x and
    >> i'd like to base on something actual.

    >
    > I do not *believe* this is true.
    >
    > <http://pypi.python.org/pypi/cloudooo/1.0.9> for instance is Python 2.6
    > and uses PyUNO.


    The Python installation can be replaced. Last I heard, many Linux distros
    used the platform Python, for example, instead of shipping an embedded one
    with OOo.


    > I would strongly recommend against floundering about in OOo's very
    > complex XML files - it is trivially easy to render a document unusable.


    True. It's not so much of a problem to read them, but writing a correct
    document can be tricky. What works relatively well is to write a template
    document in OOo and do programmatic replacements in it. But that's not
    guaranteed to work, either.

    Stefan
     
    Stefan Behnel, Dec 17, 2010
    #7
  8. Torsten Mohr

    Tim Harig Guest

    Re: PyUNO [Was: Read / Write OpenOffice SpreadSheet ?]

    On 2010-12-17, Adam Tauno Williams <> wrote:
    > I would strongly recommend against floundering about in OOo's very
    > complex XML files - it is trivially easy to render a document unusable.


    I do it all the time and have never had a problem. I don't generate the
    documents from scratch; I generate a template that contains everything
    that don't need to dynamically generate. Then I use one of two methods
    to to update the content.xml:

    1. In the simplest cases, I only need to change a single data field. I
    replace the literal data in the content.xml file with:

    <replace field="variable_name"/>

    Then, using a DOM implementation, I can use getElementsByTagName()
    to get all of the replace tags and send the variable name to a
    distpach that generates the text used to replace the tag.

    2. For collections of data (spreadsheet cells, table cells/rows, etc,
    I leave one piece of sample data in place. I then clone the DOM
    element that I can use as a template and delete the origional.
    Entering the data is then a simple matter of cloning the template
    element, updating the information that it contains, and adding
    it to the childNodes of the parent. Since tags all come from
    the file that Oo_Org/LibreOffice generated, the resulting markup
    will be valid.

    Once the content.xml file has been updated, I simply run jar as a
    subprocess to update the content.xml file in the ods/odt file.
     
    Tim Harig, Dec 17, 2010
    #8
  9. Torsten Mohr

    Stef Mientki Guest

    Re: PyUNO [Was: Read / Write OpenOffice SpreadSheet ?]

    On 17-12-2010 17:02, Adam Tauno Williams wrote:
    > On Fri, 2010-12-17 at 10:19 +0100, Torsten Mohr wrote:
    >> Thanks, i read about it but as i understood it, UNO needs Python 2.3.x and
    >> i'd like to base on something actual.

    > I do not *believe* this is true.
    >
    > <http://pypi.python.org/pypi/cloudooo/1.0.9> for instance is Python 2.6
    > and uses PyUNO.
    >
    > I would strongly recommend against floundering about in OOo's very
    > complex XML files - it is trivially easy to render a document unusable.
    >

    looks great,
    but is there something alike for Windows ?

    thanks,
    Stef Mientki
     
    Stef Mientki, Dec 17, 2010
    #9
  10. Torsten Mohr

    Terry Reedy Guest

    On 12/17/2010 4:19 AM, Torsten Mohr wrote:
    > Hello,
    >
    >> There is no package needed to read or write the new open document files.
    >> The files are merely a jar archive containing XML files. You can open
    >> and update them using jar as a subprocess and manipulate the XML files
    >> using your favorite XML libraries DOM/SAX/XPath/Etree/etc.

    >
    > thanks for your hint. I was aware of that, OO files are a bunch of zipped
    > XML files. But, i searh for something more comfortable/highlevel that lets
    > me just do things like doc.Cell(1, 3) = 'abc' or so.


    http://opendocumentfellowship.com/projects/odfpy

    --
    Terry Jan Reedy
     
    Terry Reedy, Dec 17, 2010
    #10
  11. On Friday 17 December 2010, 02:07:07 Torsten Mohr wrote:
    > Hi,
    >
    > i search for a possibility to access OpenOffoce SpreadSheets from
    > Python with a reasonably new version of Python.
    >
    > Can anybody point me to a package that can do this?


    http://ooopy.sourceforge.net/

    Pete
     
    Hans-Peter Jansen, Dec 18, 2010
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. alf
    Replies:
    7
    Views:
    430
    Sybren Stuvel
    Sep 4, 2006
  2. HokBen
    Replies:
    0
    Views:
    748
    HokBen
    Nov 9, 2006
  3. News123
    Replies:
    0
    Views:
    292
    News123
    Apr 28, 2010
  4. Grehom

    OpenOffice Spreadsheet

    Grehom, Nov 17, 2008, in forum: Perl Misc
    Replies:
    2
    Views:
    171
    Grehom
    Nov 20, 2008
  5. Skip Montanaro

    Reading OpenOffice spreadsheet in Python?

    Skip Montanaro, May 20, 2014, in forum: Python
    Replies:
    6
    Views:
    89
    Skip Montanaro
    May 21, 2014
Loading...

Share This Page