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:\Book1.xlsx")
values = find(wb, "NAS019")
wb = Workbook()
ws = wb.active
for value in values:
ws.append([value])
wb.save(filename="C:\Book2.xlsx")
Basically, I just want the output file to have highlighted rows and columns. So, when you open the output file all the information should be highlighted.