Skip to main content

A pure-Python module for writing OpenDocument spreadsheets (similar to csv.writer).

Project description

odswriter
=========

A pure-Python module for writing OpenDocument spreadsheets (similar to csv.writer).

[![Build Status](https://travis-ci.org/mmulqueen/odswriter.png?branch=master)](https://travis-ci.org/mmulqueen/odswriter)

Features
-------------
- Pure python
- Automatically converts Python types into OpenDocument equivalents
- Includes support for datetime, date and time types
- Includes support for Decimal type
- Compatible with Python 2.7 and 3.3 (and probably others)
- Support for writing formulae (but not evaluating their results)

License
-----------
The MIT License (MIT), refer to LICENSE.txt

Example
---------
```python
import datetime
import decimal
import odswriter as ods


# Single sheet mode
with ods.writer(open("test.ods","wb")) 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 ods.writer(open("test-multi.ods","wb")) 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 (see Travis CI) for compatibility with LibreOffice and Gnumeric. Compatibility with OpenOffice
should be good.

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:

```python
import odswriter as ods

with ods.writer(open("test-multi.ods","wb")) as odsfile:
my_sheet = odsfile.new_sheet("My Sheet", cols=3)
my_sheet.writerows([["One"],
["Two", "Four", "Sixteen"],
["Three", "Nine", "Twenty seven"]])

```

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

odswriter-0.4.0.tar.gz (5.9 kB view details)

Uploaded Source

File details

Details for the file odswriter-0.4.0.tar.gz.

File metadata

  • Download URL: odswriter-0.4.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for odswriter-0.4.0.tar.gz
Algorithm Hash digest
SHA256 f4c6195dc95cc4a7c2bd98a8e174ddfb9eb98b0329ffe9a740ee825a319d62a0
MD5 fa8f5eb19468af7176ca4663fe261ca8
BLAKE2b-256 328aee8f99d639c5ae4861b55f955f7941730f559ddb753977e48bd920752e5e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page