I have the code below, it use for looking a match cell value and return the row of match cell value, such as looking value is 'LogiGear' at cell D57 (row 58), it will return the row 58. I wanna improve this code, just looking for D column only. I don't know why it return the error 'invalid class string'.
Any advice?
'''
get excell row number via MS
'''
def GetExcellRowNumberViaMS(strFile, strSheet, text):
try:
bFound = False
#Create an instance of Excel.Application
xlApp = win32com.client.Dispatch("Excel.Application")
lnRowNumber=0;
i = 1
lastrow = xlSheet.UsedRange.Rows.Count
lastcol = xlSheet.UsedRange.Columns.Count
while(i<65000 and bFound ==False):
if(i == lastrow+1):
break
j = 1
while(j<256):
if(j == lastcol+1):
break
value = str(xlSheet.Cells(i,j).Text)
if(value.strip() == str(text).strip()):
lnRowNumber = i
bFound = True
break
j = j + 1
i = i + 1
return lnRowNumber
except Exception:
return 0

xlrdlibrary for Python..pyfile?