Feb-28-2021, 03:29 PM
(Feb-28-2021, 10:54 AM)buran Wrote: line 13 of your code is
sheet["CE"] = "vl"import json from collections import namedtuple from openpyxl import Workbook from openpyxl.utils import column_index_from_string Cell = namedtuple('Cell', 'row column value') def search_for_value(data, lookup_value): for row, values in data.items(): for column, cell_value in values.items(): if cell_value == lookup_value: yield Cell(row, column, cell_value) num = 50 OFFSET = 5 spam = "your JSON string here" data = json.loads(spam) for cell in search_for_value(data, num): print(cell) ws.cell(row=int(cell.row), column=column_index_from_string(cell.column)+OFFSET, value=cell.value) wb.save(filename="aexa_append.xlsx")