By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,898 Members | 1,325 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,898 IT Pros & Developers. It's quick & easy.

Has anyone generated Open Office Calc XML files from python

P: n/a
vj
I have a program which generates xml files for excel but these files
are not recognized by open office calc. I looked at the OO uno library,
but it seems like an over kill.

In my experience, for simpler documents, it is much faster to directly
write to underlying XML format. Has anyone done this? Any idea on the
XML format used by Open Office Calc?

VJ

Nov 16 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
vj
I just found something in perl:

http://tools.openoffice.org/profilin...gFile/XML.html

Will try and reverse engineer this, unless something like this exists
in python.

VJ

Nov 16 '06 #2

P: n/a

vj wrote:
I just found something in perl:

http://tools.openoffice.org/profilin...gFile/XML.html

Will try and reverse engineer this, unless something like this exists
in python.

VJ
Isn't generating CSV output suitable to your needs?
Python's CSV module makes that very simple - unless you want to include
images, etc. in the XLS file?

Vasudev
~~~~~~~~~~~~~~~~~~~~~~
Vasudev Ram
Dancing Bison Enterprises
Software consulting and training,
custom software development
http://www.dancingbison.com
http://sourceforge.net/projects/xtopdf
~~~~~~~~~~~~~~~~~~~~~~

Nov 16 '06 #3

P: n/a
vj wrote:
I have a program which generates xml files for excel but these files
are not recognized by open office calc. I looked at the OO uno library,
but it seems like an over kill.
this could be a start:

http://ooopy.sourceforge.net/

</F>

Nov 16 '06 #4

P: n/a
vj
http://ooopy.sourceforge.net/
I downloaded the package. unfortunately there are no examples that come
with. I found another python package which is more geared to creating
simple calc objects from python at. Apparently it is a port of the perl
library.

http://sourceforge.net/project/showf...group_id=87437

Here is one of the examples from the library. Seems pretty simple and
exactly what I was looking for:

-----------------------------------------------------------------------
import ooolib

# Create your document
doc = ooolib.Calc()

# Set values. The values are set in column, row order, but the values
are
# not in the traditional "A5" style format. Instead we require two
integers.
# set_cell_value(col, row, datatype, value)
for row in range(1, 9):
for col in range(1, 9):
doc.set_cell_value(col, row, "float", col * row)

# Save the document to the file you want to create
doc.save("calc-example01.ods")

-----------------------------------------------------------------------
VJ

Nov 16 '06 #5

P: n/a
vj
Isn't generating CSV output suitable to your needs?
Python's CSV module makes that very simple - unless you want to include
images, etc. in the XLS file?
You cannot create multiple worksheets using this method, or apply any
other form of formatting.

VJ

Nov 16 '06 #6

P: n/a

vj wrote:
Isn't generating CSV output suitable to your needs?
Python's CSV module makes that very simple - unless you want to include
images, etc. in the XLS file?

You cannot create multiple worksheets using this method, or apply any
other form of formatting.

VJ
Ok, got it.

Nov 18 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.