Skip to main content

Replace key words to attachments inside a document of MS Word

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.

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')

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.3.tar.gz (8.7 kB view hashes)

Uploaded Source

Built Distribution

docx_replace_attach-0.0.3-py3-none-any.whl (9.0 kB view hashes)

Uploaded 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