- 공공기관2/3 작업본 + 오늘 제출 17곳 D~J 카테고리 셀병합 정상화 - 한국지역난방공사 옵션2(고아셀 F98 수정)+전행 높이17 - 제출_프리랜서2_2026-06-21.zip 생성(17개 xlsx, 2,468행) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
18 lines
596 B
Python
18 lines
596 B
Python
# -*- coding: utf-8 -*-
|
|
"""후행 빈/잔재 행 삭제: python _trim_tail.py {xlsx경로}"""
|
|
import sys,io,openpyxl
|
|
sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')
|
|
f=sys.argv[1]
|
|
wb=openpyxl.load_workbook(f); ws=wb.active
|
|
N=ws.max_row; last=2
|
|
for r in range(3,N+1):
|
|
if ws.cell(r,2).value is not None: last=r
|
|
if N>last:
|
|
for m in list(ws.merged_cells.ranges):
|
|
if m.min_row>last: ws.unmerge_cells(str(m))
|
|
ws.delete_rows(last+1, N-last)
|
|
wb.save(f)
|
|
print(f'{last-2}행 유지·후행 {N-last}행 삭제')
|
|
else:
|
|
print(f'{last-2}행·후행잔재없음')
|