Merge branch 'fix/rps-docx-corrupt-nested-table' into main

This commit is contained in:
Power BI Dev
2026-08-09 17:37:22 +07:00
2 changed files with 11 additions and 1 deletions
+11 -1
View File
@@ -39,7 +39,17 @@ PRODI = os.environ.get("PRODI", "PROGRAM STUDI INFORMATIKA")
def _set_text(cell, text, align=None, bold=None): def _set_text(cell, text, align=None, bold=None):
"""Ganti isi sel; gaya paragraf/tabel template dipertahankan.""" """Ganti isi sel; gaya paragraf/tabel template dipertahankan.
Beberapa sel template resmi (mis. contoh isian "peta CPL-CPMK") memuat
tabel kecil bersarang di antara paragraf petunjuknya. w:tc yang berakhir
dengan w:tbl tanpa w:p setelahnya melanggar skema OOXML — Word
menganggap dokumennya rusak dan mem-"perbaiki" (merapikan ulang) sendiri
saat dibuka, yang justru merusak tata letak. Buang tabel bersarang itu
sekalian saat sel ditimpa teks baru.
"""
for tbl in cell._tc.findall(qn("w:tbl")):
tbl.getparent().remove(tbl)
for p in cell.paragraphs[1:]: for p in cell.paragraphs[1:]:
p._p.getparent().remove(p._p) p._p.getparent().remove(p._p)
p = cell.paragraphs[0] p = cell.paragraphs[0]
Binary file not shown.