python 自動生成不同行高的word
# -*- coding: utf-8 -*-
from docx import Document
from docx.shared import Cm, Pt, Inches
from docx.oxml import OxmlElement
from docx.oxml.ns import qn
from docx.enum.text import WD_ALIGN_PARAGRAPHclass DynamicTableGenerator:def __init__(self):self.doc = Document()self._setup_page()self.line_height_factor = 1.5 # 行高系數(根據實際調整)self.header_row = Noneself.current_table = Noneself.column_widths = []def _setup_page(self):# 設置全局樣式(小四號/12磅)style = self.doc.styles['Normal']style.font.name = '宋體'style.font.size = Pt(10)style._element.rPr.rFonts.set(qn('w:eas