Basically, iterate in the excel sheets, in each row, and each cell, and look for the pattern. Then write one string per row in the output file.
from openpyxl import load_workbook, Workbook
def find(wb, string):
res = []
for ws in wb:
for row in ws.values:
for value in row:
if value is not None and string in str(value):
res.append(value)
return res
if __name__ == '__main__':
wb = load_workbook("C:\op.xlsx")
values = find(wb, "findme") # Replace findme with the string to find
wb = Workbook()
ws = wb.active
for value in values:
ws.append([value])
wb.save(filename="out.xlsx") # change out.xlsx with the output file name