import openpyxl
wb=openpyxl.load_workbook("한국임업진흥원_backup_tab01전개전.xlsx")
ws=wb.active
print("backup rows:", ws.max_row)
# merged map
filled={}
for m in ws.merged_cells.ranges:
    top=ws.cell(m.min_row,m.min_col).value
    for r in range(m.min_row,m.max_row+1):
        for c in range(m.min_col,m.max_col+1):
            filled[(r,c)]=top
def eff(r,c): return filled.get((r,c), ws.cell(r,c).value)
# find 목재제품정보 and verify a few G-dict anchor rows
targets={7,10,26,37,53}
for r in range(3,ws.max_row+1):
    e=[eff(r,c) for c in range(4,11)]
    leaf=-1
    for i,v in enumerate(e):
        if v is not None and str(v).strip(): leaf=i
    k=ws.cell(r,11).value
    label=e[leaf] if leaf>=0 else ""
    if "목재제품정보" in str(label) or "tech_02.do" in str(k):
        print(f"★ r{r} leaf_col={leaf+4}(={'DEFGHIJ'[leaf]}) label='{label}' K={k}")
        print(f"   L={ws.cell(r,12).value} M={ws.cell(r,13).value} N={ws.cell(r,14).value} O={ws.cell(r,15).value}")
    if r in targets:
        print(f"  check r{r}: label='{label}' K={k}")
