README.rst 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. xlrd
  2. ====
  3. |Build Status|_ |Coverage Status|_ |Documentation|_ |PyPI version|_
  4. .. |Build Status| image:: https://circleci.com/gh/python-excel/xlrd/tree/master.svg?style=shield
  5. .. _Build Status: https://circleci.com/gh/python-excel/xlrd/tree/master
  6. .. |Coverage Status| image:: https://codecov.io/gh/python-excel/xlrd/branch/master/graph/badge.svg?token=lNSqwBBbvk
  7. .. _Coverage Status: https://codecov.io/gh/python-excel/xlrd
  8. .. |Documentation| image:: https://readthedocs.org/projects/xlrd/badge/?version=latest
  9. .. _Documentation: http://xlrd.readthedocs.io/en/latest/?badge=latest
  10. .. |PyPI version| image:: https://badge.fury.io/py/xlrd.svg
  11. .. _PyPI version: https://badge.fury.io/py/xlrd
  12. xlrd is a library for reading data and formatting information from Excel
  13. files in the historical ``.xls`` format.
  14. .. warning::
  15. This library will no longer read anything other than ``.xls`` files. For
  16. alternatives that read newer file formats, please see http://www.python-excel.org/.
  17. The following are also not supported but will safely and reliably be ignored:
  18. * Charts, Macros, Pictures, any other embedded object, **including** embedded worksheets.
  19. * VBA modules
  20. * Formulas, but results of formula calculations are extracted.
  21. * Comments
  22. * Hyperlinks
  23. * Autofilters, advanced filters, pivot tables, conditional formatting, data validation
  24. Password-protected files are not supported and cannot be read by this library.
  25. Quick start:
  26. .. code-block:: python
  27. import xlrd
  28. book = xlrd.open_workbook("myfile.xls")
  29. print("The number of worksheets is {0}".format(book.nsheets))
  30. print("Worksheet name(s): {0}".format(book.sheet_names()))
  31. sh = book.sheet_by_index(0)
  32. print("{0} {1} {2}".format(sh.name, sh.nrows, sh.ncols))
  33. print("Cell D30 is {0}".format(sh.cell_value(rowx=29, colx=3)))
  34. for rx in range(sh.nrows):
  35. print(sh.row(rx))
  36. From the command line, this will show the first, second and last rows of each sheet in each file:
  37. .. code-block:: bash
  38. python PYDIR/scripts/runxlrd.py 3rows *blah*.xls