# -*- coding: utf-8 -*-
import openpyxl, sys, os, shutil, datetime
from openpyxl.styles import PatternFill
sys.stdout.reconfigure(encoding='utf-8')

FN = '한국청소년상담복지개발원.xlsx'
BLUE = 'FFBDD7EE'
bluefill = PatternFill(fill_type='solid', fgColor=BLUE, bgColor=BLUE)

wb = openpyxl.load_workbook(FN)
ws = wb.active

# target L/M/N/O per CURRENT row (rows 69..130). None => leave as-is.
# (L=12, M=13, N=14, O=15)
TARGET = {
 69: ('게시판', 216, '어문,이미지', '미부착'),   # 보도자료 bid_45
 70: ('게시판', 706, '어문,이미지', '미부착'),   # 언론에 비친 KYCI bid_7
 73: ('페이지', 1, '어문,이미지', '미부착'),     # 사회공헌활동 (gallery photos)
 74: ('게시판', 305, '어문,이미지', '미부착'),   # 유관기관소식 bid_38
 75: ('게시판', 102, '어문,이미지', '미부착'),   # 청소년상담복지센터 웹진 bid_40
 89: ('게시판', 100, '어문', '미부착'),          # 사전정보공표 (list.asp, 브라우저 100행)
 92: ('게시판', 1, '어문', '미부착'),            # 기부금품 모금 및 활용실적 (list.asp)
 113: ('게시판', 470, '어문', '미부착'),         # 채용공고 board_recruitment
}

changed = []
for r, (L, M, N, O) in TARGET.items():
    for c, v in ((12, L), (13, M), (14, N), (15, O)):
        cur = ws.cell(r, c).value
        if cur != v:
            ws.cell(r, c).value = v
            ws.cell(r, c).fill = bluefill
            changed.append((r, c, cur, v))

# backup + save
os.makedirs('_backup', exist_ok=True)
ts = datetime.datetime.fromtimestamp(os.path.getmtime(FN)).strftime('%Y%m%d_%H%M%S')
shutil.copy2(FN, os.path.join('_backup', f'_LMNO재판정전_{ts}.xlsx'))
wb.save(FN)
print('changed cells:', len(changed))
for r, c, a, b in changed:
    print(' r%d %s: %r -> %r' % (r, chr(64+c), a, b))
