Coder Social home page Coder Social logo

odswriter's Introduction

odswriter

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

Build Status

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

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, 2L, 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"])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.