Skip to main content

Library for developers to extract data from Microsoft Excel (tm) spreadsheet files

Project description

PyPI package version Supported Python versions Supported Python implementations Linux/macOS CI status Test coverage

excelrd

excelrd is a modified version of xlrd to work for the latest Python versions. xlrd will not work at Python 3.9 or newer versions.

Purpose: Provide a library for developers to use to extract data from Microsoft Excel (tm) spreadsheet files. It is not an end-user tool.

Author: John Machin

Licence: BSD-style (see licences.py)

Versions of Python supported: 3.5+.

Outside scope: excelrd will safely and reliably ignore any of these if present in the file:

  • Charts, Macros, Pictures, any other embedded object. WARNING: currently this includes embedded worksheets.

  • VBA modules

  • Formulas (results of formula calculations are extracted, of course).

  • Comments

  • Hyperlinks

  • Autofilters, advanced filters, pivot tables, conditional formatting, data validation

  • Handling password-protected (encrypted) files.

Quick start

Print all of the cell values in a specific sheet:

Sample Code:
import excelrd


def main():
    book = excelrd.open_workbook("namesdemo.xls")

    print("The number of worksheets is {}".format(book.nsheets))
    print("Worksheet name(s): {}".format(", ".join(book.sheet_names())))

    sh = book.sheet_by_index(2)
    print("{}: rows={}, cols={}".format(sh.name, sh.nrows, sh.ncols))

    for row_idx in range(sh.nrows):
        for col_idx in range(sh.ncols):
            cell = sh.cell(row_idx, col_idx)

            if not cell.value:
                continue

            print("row={}, col={}, value={}".format(row_idx, col_idx, cell.value))

Transition from xlrd to excelrd

Just replace the import xlrd:

import excelrd as xlrd

Another quick start

This will show the first, second and last rows of each sheet in each file:

python PYDIR/scripts/runxlrd.py 3rows *blah*.xls

Acknowledgements

  • This package started life as a translation from C into Python of parts of a utility called “xlreader” developed by David Giffin. “This product includes software developed by David Giffin david@giffin.org.”

  • OpenOffice.org has truly excellent documentation of the Microsoft Excel file formats and Compound Document file format, authored by Daniel Rentz. See http://sc.openoffice.org

  • U+5F20 U+654F: over a decade of inspiration, support, and interesting decoding opportunities.

  • Ksenia Marasanova: sample Macintosh and non-Latin1 files, alpha testing

  • Backporting to Python 2.1 was partially funded by Journyx - provider of timesheet and project accounting solutions (http://journyx.com/).

  • Provision of formatting information in version 0.6.1 was funded by Simplistix Ltd (http://www.simplistix.co.uk/)

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

excelrd-2.0.3.tar.gz (759.9 kB view details)

Uploaded Source

Built Distribution

excelrd-2.0.3-py3-none-any.whl (105.5 kB view details)

Uploaded Python 3

File details

Details for the file excelrd-2.0.3.tar.gz.

File metadata

  • Download URL: excelrd-2.0.3.tar.gz
  • Upload date:
  • Size: 759.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.5.9

File hashes

Hashes for excelrd-2.0.3.tar.gz
Algorithm Hash digest
SHA256 87eb026805385a2a0009e34b84533a8f020ae589de986acf2c4e6ba2e23636d0
MD5 b614a3eff870ea7a9c4ea530a3cb83b2
BLAKE2b-256 dc48a558d78f704d8ca61488b96a2c981b185ef3339bd0bcf51b65f4d9f45b8d

See more details on using hashes here.

File details

Details for the file excelrd-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: excelrd-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 105.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.5.9

File hashes

Hashes for excelrd-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a248ac32c353e7f39a9877d85c501d10cdadc62128305fb30174e91a4c1b2b0a
MD5 11af5657a32ca2e5d813beacbbb018e3
BLAKE2b-256 783ed7be8ffa1a2726c65e379b5b485442546e3654455a3ff701f11c45a47a91

See more details on using hashes here.

Supported by

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