# -*- coding: utf-8 -*-
import openpyxl, io
wb=openpyxl.load_workbook("한국지역난방공사.xlsx"); ws=wb.active
out=io.open("_inspect_out.txt","w",encoding="utf-8")
def w(*a): out.write(" ".join(str(x) for x in a)+"\n")
# map each cell to its merge range top
mtop={}
for mr in ws.merged_cells.ranges:
    for r in range(mr.min_row,mr.max_row+1):
        for c in range(mr.min_col,mr.max_col+1):
            mtop[(r,c)]="M%d:%d"%(mr.min_row,mr.max_row)
COLS={4:'D',5:'E',6:'F',7:'G'}
def show(rng):
    for r in rng:
        cells=[]
        for c in range(4,8):
            v=ws.cell(r,c).value
            vv=str(v).strip() if v not in(None,"") else "·"
            mk=mtop.get((r,c),"")
            cells.append(f"{COLS[c]}={vv}{('['+mk+']') if mk else ''}")
        w(f"r{r} B{ws.cell(r,2).value}  "+" | ".join(cells))
w("--- rows 3..12 (정보공개) ---"); show(range(3,13))
w("\n--- rows 52..64 (ESG경영) ---"); show(range(52,65))
w("\n--- rows 24..32 (경영공시/투자정보) ---"); show(range(24,33))
out.close(); print("done")
o2=io.open("_inspect2_out.txt","w",encoding="utf-8")
def w2(*a): o2.write(" ".join(str(x) for x in a)+"\n")
for r in range(94,101):
    cells=[]
    for c in range(4,9):
        v=ws.cell(r,c).value; vv=str(v).strip() if v not in(None,"") else "·"
        mk=mtop.get((r,c),"")
        cells.append(f"{ {4:'D',5:'E',6:'F',7:'G',8:'H'}[c] }={vv}{('['+mk+']') if mk else ''}")
    w2(f"r{r} B{ws.cell(r,2).value}  "+" | ".join(cells))
o2.close()
