跳转到主要内容

创建和更新Microsoft Word .docx文件。

项目描述

python-docx-whtsky

https://travis-ci.cn/whtsky/python-docx.svg?branch=master

python-docx-whtsky 是一个用于创建和更新Microsoft Word (.docx)文件的Python库。

更多信息请参阅python-docx文档

发布历史

0.8.10.3 (2019-11-11)

  • TableCell的add_table方法现在接受firstCol, firstRow, lastCol, lastRow, hBand, vBand

0.8.10.2 (2019-10-23)

示例

https://github.com/python-openxml/python-docx/issues/25#issuecomment-143231954

from docx import Document

document = Document()

# Add desired numbering styles to your template file.

# Extract abstractNumId from there. In this example, abstractNumId is 10

numId = document.get_new_list("10")

# Add a list

p = document.add_paragraph(style = 'ListParagraph', text = "a")
p.num_id = numId
p.level = 0
p = document.add_paragraph(style = 'ListParagraph', text = "b")
p.num_id = numId
p.level = 1
p = document.add_paragraph(style = 'ListParagraph', text = "c")
p.num_id = numId
p.level = 1
p = document.add_paragraph(style = 'ListParagraph', text = "d")
p.num_id = numId
p.level = 0
p = document.add_paragraph(style = 'ListParagraph', text = "e")
p.num_id = numId
p.level = 1
p = document.add_paragraph(style = 'ListParagraph', text = "f")
p.num_id = numId
p.level = 0

# Restart numbering at the outer level

numId = document.get_new_list("10")

# Add the same list once again. The numbering is restarted

p = document.add_paragraph(style = 'ListParagraph', text = "a")
p.num_id = numId
p.level = 0
p = document.add_paragraph(style = 'ListParagraph', text = "b")
p.num_id = numId
p.level = 1
p = document.add_paragraph(style = 'ListParagraph', text = "c")
p.num_id = numId
p.level = 1
p = document.add_paragraph(style = 'ListParagraph', text = "d")
p.num_id = numId
p.level = 0
p = document.add_paragraph(style = 'ListParagraph', text = "e")
p.num_id = numId
p.level = 1
p = document.add_paragraph(style = 'ListParagraph', text = "f")
p.num_id = numId
p.level = 0

document.save("num.docx")

0.8.10.1 (2019-10-16)

项目详情


下载文件

下载适合您平台的文件。如果您不确定该选择哪个,请了解有关 安装包 的更多信息。

源代码分发

python-docx-whtsky-0.8.10.3.tar.gz (5.5 MB 查看哈希值)

上传时间 源代码

构建分发

python_docx_whtsky-0.8.10.3-py2.py3-none-any.whl (183.2 kB 查看哈希值)

上传时间 Python 2 Python 3

支持者