I was working on a project in which I was looking for an .xlsx document for a cell containing a specific "x" value. I managed to get this far, but I cannot extract the location of the specified cell.
This is the code I came up with:
from openpyxl import load_workbook
wb = load_workbook(filename = 'Abstract.xlsx', use_iterators = True)
ws = wb.get_sheet_by_name(name = 'Abstract')
for row in ws.iter_rows():
for cell in row:
if cell.value == "E01234":
print "TRUE"
When I run this script, if there is a cell with the value "E01234" in the referenced .xlsx file, it prints TRUE. Now I need to get the address of the row and column (that is: A4) of the cell with the value "E01234". Next in my project
I want to change another cell on the same line as the identified one.
Any ideas?
source
share