Git Product home page Git Product logo

openpyxl's Introduction

OpenPyxl is a Python library to read/write Excel 2007 xlsx/xlsm files.

It was born from lack of existing library to read/write natively from Python the new Open Office XML format.

All kudos to the PHPExcel team as openpyxl is a Python port of PHPExcel http://www.phpexcel.net/

== User List ==
Official user list can be found on http://groups.google.com/group/openpyxl-users

== Contribute ==
Any help will be greatly appreciated, there are just a few requirements to get your code checked in the public repository:
* Mercurial bundles are the preferred way of contributing code, compared to diffs written in a text file. Forks are encouraged, but don't forget to make a pull request if you want your code to be included :)
* long diffs posted in the body of a tracker request will not be looked at (more than 30 rows of non-syntax highlighted code is simply unreadable). Please attach your bundle files to the issue instead.
* every non-trivial change must come with at least a unit test (that tests the new behavior, obviously :p). There are plenty of examples in the /test directory if you lack know-how or inspiration.

== Easy Install ==
Releases are also packaged on PyPi, so all you have to type to get the latest version is:

    $ easy_install openpyxl

== Features ==

** Supported data types **
    * String (shared, Inline not currently supported)
    * Integer
    * Float
    * Date

** Supported Excel features **
    * Names ranges
    * Number formats (built-in and custom formats)

** Handy features **
    * Implicit conversion between Python types and Excel types:
        * Dates
        * Floats
        * Percentages
    * Optimized modes to read and write extremely large files

== Python 3.x support ==

Openpyxl supports python (even if some tests can fail on 2.4) from 2.4 to 3.2. 

== Full documentation==
With tutorial, examples, API documentation: http://packages.python.org/openpyxl/

== Quick Examples ==

=== Write a workbook ===

    #!python
    from openpyxl.workbook import Workbook
    from openpyxl.writer.excel import ExcelWriter

    from openpyxl.cell import get_column_letter

    wb = Workbook()

    dest_filename = r'empty_book.xlsx'

    ws = wb.worksheets[0]

    ws.title = "range names"

    for col_idx in xrange(1, 40):
        col = get_column_letter(col_idx)
        for row in xrange(1, 600):
            ws.cell('%s%s'%(col, row)).value = '%s%s' % (col, row)

    ws = wb.create_sheet()

    ws.title = 'Pi'

    ws.cell('F5').value = 3.14

    wb.save(filename = dest_filename)

=== Read an existing workbook ===

    #!python
    from openpyxl.reader.excel import load_workbook

    wb = load_workbook(filename = r'empty_book.xlsx')

    sheet_ranges = wb.get_sheet_by_name(name = 'range names')

    print sheet_ranges.cell('D18').value # D18

=== Number Formats ===

    #!python
    import datetime
    from openpyxl.workbook import Workbook

    wb = Workbook()
    ws = wb.worksheets[0]

    # set date using a Python datetime
    ws.cell('A1').value = datetime.datetime(2010, 7, 21)

    print ws.cell('A1').style.number_format.format_code # returns 'yyyy-mm-dd'

    # set percentage using a string followed by the percent sign
    ws.cell('B1').value = '3.14%'

    print ws.cell('B1').value # returns 0.031400000000000004

    print ws.cell('B1').style.number_format.format_code # returns '0%'

openpyxl's People

Contributors

adamlofts avatar adammorris avatar agronholm avatar anders-chrigstrom avatar bgelineau avatar csilvers avatar dieterv77 avatar ericgazoni avatar etienned avatar greglehmann-wf avatar gurneyalex avatar jamesfysh avatar josephtate avatar lanyjie avatar lukecyca avatar maartendp avatar osuchw avatar samh avatar smagala avatar themanwithoutaplan avatar tynril avatar vasseur avatar zenweasel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.