mmulqueen / odswriter Goto Github PK
View Code? Open in Web Editor NEWA pure-Python module for writing OpenDocument spreadsheets (similar to csv.writer).
License: MIT License
A pure-Python module for writing OpenDocument spreadsheets (similar to csv.writer).
License: MIT License
A user reports that generated files cannot be opened by Gnumeric, the error given relates to a missing styles.xml file.
I encountered an incompatibility with the Java library jOpenDocument. Unfortunately I don't know whether it is odswriter or jopendocument which is misbehaving.
I tried to write an ods file using odswriter:
table = []
row = ["A", "B"]
table.append(row)
out_stream = io.BytesIO()
with odswriter.writer(out_stream) as out:
out.writerows(table)
Then, I return this in an HTTPResponse to let someone download the ods file.
If this is opened in LibreOffice, everything is fine.
It the jOpenDocument library tries to open the ods file, the following Exception occures:
Exception in thread "Thread-2" java.lang.IllegalStateException: parse error
at org.jopendocument.dom.ODPackage$1.processEntry(Unknown Source)
at org.jopendocument.util.ZippedFilesProcessor.process(Unknown Source)
at org.jopendocument.dom.ODPackage.<init>(Unknown Source)
at org.jopendocument.dom.ODPackage.<init>(Unknown Source)
at org.jopendocument.dom.spreadsheet.SpreadSheet.createFromFile(Unknown Source)
...
Caused by: org.jdom.input.JDOMParseException: Error on line 8: Präfix "style" für Attribut "style:name", das mit Elementtyp "number:time-style" verknüpft ist, ist nicht gebunden.
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:533)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:865)
... 8 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 57; Präfix "style" für Attribut "style:name", das mit Elementtyp "number:time-style" verknüpft ist, ist nicht gebunden.
This happens with jOpenDocument version 1.3 and 1.4 rc2.
If I have 4 columns and 2 lines (or 3)
e.g.:
tab = [["col1","col2","col2","col4"],["test1","test2","test3","test4"],["test5","test6","test7","test8"]],
and use function writerows():
writerows(tab)
then you library print error:
"Exception: More cells than cols.". Error in line 113
and I can`t export this to file.
odswriter was not working for me, the Formulas would not be interpreted by Libreoffice 6.4.7.
But removing the code that wraps the cell references in brackets and add a dot before cell references in the Formula class fixed the problem.
# DO NOT Wrap cell refs in square brackets.
# s = re.sub(r"([A-Z]+[0-9]+(:[A-Z]+[0-9]+)?)", r"[\1]", s)
# DO NOT Place a . before cell references, so for example . A2 becomes .A2
# s = re.sub(r"([A-Z]+[0-9]+)(?!\()", r".\1", s)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.