I am currently trying to write a script that will evaluate a spreadsheet to search column A for a string, and then once it finds that string, print the value of column I in the same row. So far I have the following code but it isn't getting me very far.
any help will be appreciated.
import openpyxl
wb = openpyxl.load_workbook("2016_SF.xlsx", data_only=True)
ws = wb["161226-161228"]
last_r=70
search_str = raw_input("What plant are you looking for? > ")
last_r = cell.row
def FindXlCell(search_str,last_r):
for row in ws.iter_rows(row_offset=last_r):
for cell in row:
if (search_str == cell.value):
print(search_str, last_r, cell.row,)
Worksheet in test.xlsx:
Usage with other range examples:
Search the whole sheet
Starting with Row 2 and match only on Column 3 == 'C':
Limit the Range from Row 2 to Row 3:
It's also posible to use 'ws.iter_cols(...' or any other function that will return a squared_range:
Tested with Python:3.4.2 - openpyxl:2.4.1 - LibreOffice:4.3.3.2