searchstring并获取行和列的值
如何在Excel表格中search特定的string,并使用python中的xlrd
获取Excel表格中特定string的行和列值? 任何人都可以帮我吗?
import xlrd workbook = xlrd.open_workbook("1234.xls") worksheet = workbook.sheet_by_name('firstpage')
只有这么多我试过
我想这就是你要找的,在这里,
from xlrd import open_workbook book = open_workbook(workbookName) for sheet in book.sheets(): for rowidx in range(sheet.nrows): row = sheet.row(rowidx) for colidx, cell in enumerate(row): if cell.value == "particularString" : print sheet.name print colidx print rowidx
最好,
假设你正在寻找一个strings
:
for row in range(sh.nrows): for column in range(sh.ncols): if s == sh.cell(row, column).value: return (row, column)