INNER CODE UNIT · Python
set_cell_margins
sangrokjung/claude-forge · scripts/md-to-docx/convert.py:99
def set_cell_margins(cell, top=0, bottom=0, left=80, right=80):
"""셀 내부 마진 설정 (단위: twips)"""
tc = cell._tc
tcPr = tc.get_or_add_tcPr()
tcMar = OxmlElement('w:tcMar')
for edge, val in [('top', top), ('bottom', bottom), ('start', left), ('end', right)]:
el = OxmlElement(f'w:{edge}')
el.set(qn('w:w'), str(val))
el.set(qn('w:type'), 'dxa')
tcMar.append(el)
existing = tcPr.find(qn('w:tcMar'))
if existing is not None:
tcPr.remove(existing)
tcPr.append(tcMar)