Skip to main content

Replace key words to attachments inside a document of MS Word or Excel

Project description

docx-replace-attach

License GitHub release GitHub stars GitHub forks

This library was built on top of python-docx and the main purpose is to replace key words to attachments inside a document of MS Word.

Just like this:
Example

Getting started

You can define a key in your Word document This program requires the following key format: {key_name}

How to install

pip3 install docx-replace-attach

How to use

Example:

from docx import Document
from docx_attachment import replace_xlsx
from docx_attachment import replace_docx


# The template file
doc = Document('template.docx')

# replace key_name to a word file, key_name is word_attachment, word file is word_attachment.docx
replace_docx(doc, 'word_attachment', 'word_attachment.docx')

# replace key_name to a excel file, key_name is excel_attachment, excel file is excel_attachment.xlsx
replace_xlsx(doc, 'excel_attachment', 'excel_attachment.xlsx')

# save as a new file
doc.save('new.docx')

You can also use:

from docx_attachment import replace_xlsx_in_template
from docx_attachment import replace_docx_in_template


replace_docx_in_template('template.docx', 'new.docx', 'word_attachment', 'word_attachment.docx')

replace_xlsx_in_template('template.docx', 'new.docx', 'excel_attachment', 'excel_attachment.xlsx')

Stargazers over time

Stargazers over time

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

docx_replace_attach-0.0.5.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docx_replace_attach-0.0.5-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file docx_replace_attach-0.0.5.tar.gz.

File metadata

  • Download URL: docx_replace_attach-0.0.5.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for docx_replace_attach-0.0.5.tar.gz
Algorithm Hash digest
SHA256 3a431fb07df23e411db232b4f9193107fa2e37e409701f5cd98aeb4f739de69e
MD5 112a08d2360cac6fdd9ddd7776bc8a91
BLAKE2b-256 a3737c43b5132f0244100ea2d9193212f1cf2ee5e3817ab688f5e571acb9ecf5

See more details on using hashes here.

File details

Details for the file docx_replace_attach-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for docx_replace_attach-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 db98c23b5c354ecaeffa1022b512c7f76162969df036f175fd97146d937c6a0f
MD5 604186b746769b959838bdac53e3392b
BLAKE2b-256 22ccd6201b7eb788f23a9d1a6f23c3f03b7ce07dbfa3f319ffbbe2b2bee25c6d

See more details on using hashes here.

Supported by

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