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 bdesc(cell):
    b=cell.border
    def s(side): return f'{side.style}'
    return f'L={s(b.left)} R={s(b.right)} T={s(b.top)} B={s(b.bottom)}'

print('=== row 233 borders (template) cols A..AA ===')
for c in range(1,28):
    cell=ws.cell(233,c)
    print(f'  {cell.coordinate}: {bdesc(cell)}')

# classify each data row: has full thin border on B..S (cols 2..19) vs none
print('\n=== rows lacking borders (B..S any side None) ===')
def has_border(r):
    for c in range(2,20):  # B..S
        b=ws.cell(r,c).border
        if not (b.left.style and b.right.style and b.top.style and b.bottom.style):
            return False
    return True
noborder=[r for r in range(3,ws.max_row+1) if not has_border(r)]
# compress to ranges
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 out
print('no-border rows count:', len(noborder))
print('ranges:', [(a,b) for a,b in ranges(noborder)])

# sample one no-border row border detail
if noborder:
    r=noborder[0]
    print(f'\nsample no-border r{r}:')
    for c in range(1,20):
        print(f'  {ws.cell(r,c).coordinate}: {bdesc(ws.cell(r,c))}')
