Skip to main content

Replace key words to attachments inside a document of MS Word

Project description

docx-replace-attach

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.

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_word


# 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_word(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_t
from docx_attachment import replace_word_t


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

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

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.2.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

docx_replace_attach-0.0.2-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file docx-replace-attach-0.0.2.tar.gz.

File metadata

  • Download URL: docx-replace-attach-0.0.2.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for docx-replace-attach-0.0.2.tar.gz
Algorithm Hash digest
SHA256 f64df36c0d6d18785011b83337f791482846e9142480d5dd5bb5c4ac6cd8b2f7
MD5 da54b506001f8ca643dd37213fb4c47b
BLAKE2b-256 98447e468d3bc0d11fa8360205be8ba8ab72dca7b3e56c909b842d70e63b133e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for docx_replace_attach-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 86f67988d9702e45fcf0bd7c0d8e61a565fa664eb7c8553a76b4d4b33678d7fa
MD5 62fa20d77f51fb4d9a4492b717fd3969
BLAKE2b-256 928717d20bd74ec6728c98fc3e3453e2793a206049d403bfbce682f229845549

See more details on using hashes here.

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