A pure-Python module for writing OpenDocument spreadsheets (similar to csv.writer).
Project description
odswriter
This library receives minimal maintenance, but it is luckily very simple.
A pure-Python module for writing OpenDocument spreadsheets (similar to csv.writer).
Features
- Pure python
- Automatically converts Python types into OpenDocument equivalents
- Includes support for datetime, date and time types
- Includes support for Decimal type
- Tested on Python 3.9, 3.10, 3.11, 3.12, 3.13
- Support for writing formulae (but not evaluating their results)
License
The MIT License (MIT), refer to LICENSE.txt
Installation
Available on PyPI: https://pypi.org/project/odswriter/
pip install odswriter
Example
import datetime
import decimal
import odswriter as ods
# Single sheet mode
with open("test.ods", "wb") as f:
with ods.writer(f) as odsfile:
odsfile.writerow(["String", "ABCDEF123456", "123456"])
# Lose the 2L below if you want to run this example code on Python 3, Python 3 has no long type.
odsfile.writerow(["Float", 1, 123, 123.123, decimal.Decimal("10.321")])
odsfile.writerow(["Date/DateTime", datetime.datetime.now(), datetime.date(1989, 11, 9)])
odsfile.writerow(["Time",datetime.time(13, 37),datetime.time(16, 17, 18)])
odsfile.writerow(["Bool", True, False, True])
odsfile.writerow(["Formula", 1, 2, 3, ods.Formula("IF(A1=2,B1,C1)")])
# Multiple sheet mode
with open("test-multi.ods", "wb") as f:
with ods.writer(f) as odsfile:
bears = odsfile.new_sheet("Bears")
bears.writerow(["American Black Bear", "Asiatic Black Bear", "Brown Bear", "Giant Panda", "Qinling Panda",
"Sloth Bear", "Sun Bear", "Polar Bear", "Spectacled Bear"])
sloths = odsfile.new_sheet("Sloths")
sloths.writerow(["Pygmy Three-Toed Sloth", "Maned Sloth", "Pale-Throated Sloth", "Brown-Throated Sloth",
"Linneaeus's Two-Twoed Sloth", "Hoffman's Two-Toed Sloth"])
Compatibility
Odswriter is tested for compatibility with LibreOffice and Gnumeric.
jOpenDocument is not compatible out-of-the-box, but by specifying the number of columns (odswriter will pad with empty cells up to that number) it can be made compatible. Code example:
import odswriter as ods
with open("test-multi.ods", "wb") as f:
with ods.writer(f) as odsfile:
my_sheet = odsfile.new_sheet("My Sheet", cols=3)
my_sheet.writerows([["One"],
["Two", "Four", "Sixteen"],
["Three", "Nine", "Twenty seven"]])
Testing
LibreOffice and Gnumeric are used to verify the output of odswriter if installed.
uv run python3 -m unittest discover -s tests
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file odswriter-0.5.0.tar.gz.
File metadata
- Download URL: odswriter-0.5.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4290dcb00795460a141a8f6451dc5d08972635452e8d0ae9a88427687340bde
|
|
| MD5 |
d3bd69602802376abb8ce30b2e39b8f8
|
|
| BLAKE2b-256 |
3711322e17cf4304604ed3e8ea326ab60946ba3f8867f66e6153ee6bd0048a70
|
Provenance
The following attestation bundles were made for odswriter-0.5.0.tar.gz:
Publisher:
python-release.yml on mmulqueen/odswriter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
odswriter-0.5.0.tar.gz -
Subject digest:
a4290dcb00795460a141a8f6451dc5d08972635452e8d0ae9a88427687340bde - Sigstore transparency entry: 1804015125
- Sigstore integration time:
-
Permalink:
mmulqueen/odswriter@ad087b806a7ff191cefc315518579b73ccd3a1a3 -
Branch / Tag:
refs/tags/0.5.0 - Owner: https://github.com/mmulqueen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yml@ad087b806a7ff191cefc315518579b73ccd3a1a3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file odswriter-0.5.0-py3-none-any.whl.
File metadata
- Download URL: odswriter-0.5.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
184e53676a5af1adcd3b08a05dec59690fda7f50a26b225005126b6711f3ee80
|
|
| MD5 |
963abc67ccc755cf35c6ec2c3d6dcdc4
|
|
| BLAKE2b-256 |
3b092da39db5d5e0feb7c1227b691c5e911e99bde5cb0e405afe15bde6fed102
|
Provenance
The following attestation bundles were made for odswriter-0.5.0-py3-none-any.whl:
Publisher:
python-release.yml on mmulqueen/odswriter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
odswriter-0.5.0-py3-none-any.whl -
Subject digest:
184e53676a5af1adcd3b08a05dec59690fda7f50a26b225005126b6711f3ee80 - Sigstore transparency entry: 1804015231
- Sigstore integration time:
-
Permalink:
mmulqueen/odswriter@ad087b806a7ff191cefc315518579b73ccd3a1a3 -
Branch / Tag:
refs/tags/0.5.0 - Owner: https://github.com/mmulqueen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yml@ad087b806a7ff191cefc315518579b73ccd3a1a3 -
Trigger Event:
release
-
Statement type: