import sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
import openpyxl
from openpyxl.utils import get_column_letter
PKG = r'D:\01.프로젝트\DB수집\작업파일\_제출패키지_2026-06-03\프리랜서1\충청남도_부여군.xlsx'
ws = openpyxl.load_workbook(PKG).active

# which columns are ever part of a merge (rows>=3)
mergecols=set()
for m in ws.merged_cells.ranges:
    if m.min_row>=3:
        for c in range(m.min_col,m.max_col+1): mergecols.add(c)
print('merged columns (>=3):', sorted(get_column_letter(c) for c in mergecols))

def anyb(cell):
    b=cell.border
    return any([b.left.style,b.right.style,b.top.style,b.bottom.style])

# cells in merge (interior or anchor)
def in_merge(r,c):
    for m in ws.merged_cells.ranges:
        if m.min_row<=r<=m.max_row and m.min_col<=c<=m.max_col:
            return True
    return False

print('\n=== per-column: rows(3-572) NOT in merge AND no border ===')
for c in range(2,28):
    miss=[r for r in range(3,ws.max_row+1) if not in_merge(r,c) and not anyb(ws.cell(r,c))]
    if miss:
        print(f'  col {get_column_letter(c)}: {len(miss)} rows  e.g. {miss[:6]}')

# row 233 per-column border presence (reference)
print('\n=== row 233 reference border (style on each side) ===')
for c in range(2,28):
    cell=ws.cell(233,c); b=cell.border
    print(f'  {get_column_letter(c)}: L={b.left.style} R={b.right.style} T={b.top.style} B={b.bottom.style}')
