# -*- coding: utf-8 -*- import openpyxl wb=openpyxl.load_workbook("한국지역난방공사.xlsx"); ws=wb.active cands=[(5,3,4),(5,26,27),(5,54,55),(5,142,143),(5,159,160),(5,202,203),(5,224,225), (6,3,5),(6,28,29),(6,46,47),(6,54,56),(6,62,63),(6,75,76),(6,107,108),(6,149,150),(6,163,164), (7,29,30),(7,46,47),(7,62,64),(7,108,109),(7,119,120),(7,163,165),(7,179,180)] existing=[(mr.min_col,mr.min_row,mr.max_row,mr.max_col) for mr in ws.merged_cells.ranges if mr.min_col==mr.max_col] prob=0 for (c,r1,r2) in cands: for (ec,er1,er2,emc) in existing: if ec==c and not(er2r2): # overlap in same col print("OVERLAP cand col%d %d:%d with existing %d:%d"%(c,r1,r2,er1,er2)); prob+=1 print("overlap problems:",prob)