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

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

# Use col K(11), L(12), G(7), B(2) as probes
for probe,name in [(2,'B'),(7,'G'),(11,'K'),(12,'L'),(14,'N'),(15,'O')]:
    no=[r for r in range(3,ws.max_row+1) if not anyb(ws.cell(r,probe))]
    def ranges(lst):
        out=[]
        for x in lst:
            if out and x==out[-1][1]+1: out[-1][1]=x
            else: out.append([x,x])
        return [(a,b) for a,b in out]
    print(f'col {name}: NO-border rows={len(no)} ranges={ranges(no)[:12]}')

# detailed: full row border completeness using probe cells that should be thin all-sides (B,F..Q,L..)
# Compare a "good" row 233 set vs others: which rows differ from having thin on K
print('\n=== K(11) border per 40-row buckets (count with border) ===')
for start in range(3, ws.max_row+1, 40):
    end=min(start+39, ws.max_row)
    cnt=sum(1 for r in range(start,end+1) if anyb(ws.cell(r,11)))
    print(f'  rows {start}-{end}: K-bordered {cnt}/{end-start+1}')
