搜索字符串并获取行和列值
Searching the string and getting the row and column value
如何在 excel sheet 中搜索特定字符串并使用 [=11] 在 excel sheet 中获取该特定字符串的行值和列值=] 在 python 中?谁能帮帮我吗?
import xlrd
workbook = xlrd.open_workbook("1234.xls")
worksheet = workbook.sheet_by_name('firstpage')
我只试了这么多
假设您正在搜索字符串 s
:
for row in range(sh.nrows):
for column in range(sh.ncols):
if s == sh.cell(row, column).value:
return (row, column)
我想这就是你要找的,给你,
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
最佳,
如何在 excel sheet 中搜索特定字符串并使用 [=11] 在 excel sheet 中获取该特定字符串的行值和列值=] 在 python 中?谁能帮帮我吗?
import xlrd
workbook = xlrd.open_workbook("1234.xls")
worksheet = workbook.sheet_by_name('firstpage')
我只试了这么多
假设您正在搜索字符串 s
:
for row in range(sh.nrows):
for column in range(sh.ncols):
if s == sh.cell(row, column).value:
return (row, column)
我想这就是你要找的,给你,
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
最佳,