python 自动生成不同行高的word
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