600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > python-docx表格设置实线_如何使用python docx设置单元格边框

python-docx表格设置实线_如何使用python docx设置单元格边框

时间:2024-03-12 14:15:32

相关推荐

python-docx表格设置实线_如何使用python docx设置单元格边框

这是我在一个项目中使用的片段。也适用于合并单元格。from docx.oxml import OxmlElement

from docx.oxml.ns import qn

def set_cell_border(cell: _Cell, **kwargs):

"""

Set cell`s border

Usage:

set_cell_border(

cell,

top={"sz": 12, "val": "single", "color": "#FF0000", "space": "0"},

bottom={"sz": 12, "color": "#00FF00", "val": "single"},

start={"sz": 24, "val": "dashed", "shadow": "true"},

end={"sz": 12, "val": "dashed"},

)

"""

tc = cell._tc

tcPr = tc.get_or_add_tcPr()

# check for tag existnace, if none found, then create one

tcBorders = tcPr.first_child_found_in("w:tcBorders")

if tcBorders is None:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。