I have an Excel sheet like this:
A B C D E F G
1 0 0 0
2 0 0
3 0
4
5 0 0 0 0 0 0 0
6 0 0 0
And every '0' represents some data values, I am reading the values and comparing them with my original data, when the data match fails it returns a message. What I want is to return the line number of excel sheet as well as the column number or particularly the CELL location. Please help me doing this!
Try this:
import xlrd
workbook = xlrd.open_workbook('book.xls')
for sheet in workbook.sheets():
for row in range(sheet.nrows):
for column in range(sheet.ncols):
print "row::::: ", row
print "column:: ", column
print "value::: ", sheet.cell(row,column).value
It will give you exact row
, column
numbers and cell
value
Keep track of the column and row while iterating over the worksheet. An xlrd
Cell
does not keep track of where they 'live' in the sheet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With