Skip to main content

Create and update Microsoft Word .docx files.

Project description

python-docx-whtsky

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

python-docx-whtsky is a Python library for creating and updating Microsoft Word (.docx) files.

More information is available in the python-docx documentation

Release History

0.8.10.3 (2019-11-11)

  • TableCell's add_table method accepts firstCol, firstRow, lastCol, lastRow, hBand, vBand) now.

0.8.10.2 (2019-10-23)

Example

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-docx-whtsky-0.8.10.3.tar.gz (5.5 MB view hashes)

Uploaded Source

Built Distribution

python_docx_whtsky-0.8.10.3-py2.py3-none-any.whl (183.2 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page