Read the excel data using xlrd module

suggest change

Python xlrd library is to extract data from Microsoft Excel (tm) spreadsheet files.

Installation:-

pip install xlrd

Or you can use setup.py file from pypi

https://pypi.python.org/pypi/xlrd

Reading an excel sheet:- Import xlrd module and open excel file using open_workbook() method.

import xlrd
book=xlrd.open_workbook('sample.xlsx')

Check number of sheets in the excel

print book.nsheets

Print the sheet names

print book.sheet_names()

Get the sheet based on index

sheet=book.sheet_by_index(1)

Read the contents of a cell

cell = sheet.cell(row,col) #where row=row number and col=column number
print cell.value #to print the cell contents

Get number of rows and number of columns in an excel sheet

num_rows=sheet.nrows
num_col=sheet.ncols

Get excel sheet by name

sheets = book.sheet_names()
cur_sheet = book.sheet_by_name(sheets[0])

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Python and Excel:
* Read the excel data using xlrd module

Table Of Contents
2 Filter
3 List
7 Loops
22 Reduce
27 Classes
31 Set
42 Tuple
45 Enum
62 Sockets
89 urllib
91 Python and Excel
92 Idioms
104 Stack
105 Profiling
109 Logging
111 os module
118 Mixins
120 ArcPy
126 Arrays
132 2to3 tool
135 Unicode
138 Neo4j
140 Curses
141 Templates
145 heapq
146 tkinter
154 Audio
155 pyglet
157 ijson
160 Flask
161 Groupby
163 pygame
165 hashlib
166 Gzip
167 ctypes
185 pyaudio
186 shelve