# -*- coding: utf-8 -*- import openpyxl, os, shutil, time f="한국지역난방공사.xlsx" mt0=os.path.getmtime(f) shutil.copy2(f,"한국지역난방공사_backup_행높이17전.xlsx") wb=openpyxl.load_workbook(f) ws=wb.active ws.sheet_format.defaultRowHeight=17 ws.sheet_format.customHeight=True mx=ws.max_row for r in range(1,mx+1): ws.row_dimensions[r].height=17 # mtime guard before save if abs(os.path.getmtime(f)-mt0)>0.5: raise SystemExit("ABORT: file changed by another process") wb.save(f) # verify wb2=openpyxl.load_workbook(f) ws2=wb2.active hs=set() for r in range(1,ws2.max_row+1): hs.add(ws2.row_dimensions[r].height) print("max_row",ws2.max_row,"distinct heights set:",hs,"default",ws2.sheet_format.defaultRowHeight)