import openpyxl,json,io,copy
from openpyxl.styles import PatternFill
BLUE=PatternFill(fgColor='FFBDD7EE',fill_type='solid')
rep=json.load(io.open('_boardM_all.json',encoding='utf-8'))
wb=openpyxl.load_workbook('한국지역난방공사.xlsx'); ws=wb.active
applied=[]; skipped=[]
for x in rep:
    r=x['r']; cur=x['curM']; new=x['newM']; tag=x['tag']
    if r==176: skipped.append((r,'임직원검색 directory est keep')); continue
    if not isinstance(new,int) or new<=0 or 'norows' in tag:
        if str(cur)!=str(new): skipped.append((r,tag,x['label']))
        continue
    if str(cur)==str(new): continue
    ws.cell(r,13).value=new
    ws.cell(r,13).fill=copy.copy(BLUE)
    applied.append((r,cur,new,x['label']))
wb.save('한국지역난방공사.xlsx')
print('applied',len(applied))
for a in applied: print('  ',a)
print('skipped(JS/empty - left as is):',len(skipped))
for s in skipped: print('  ',s)
