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')
Stargazers over time
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for docx-replace-attach-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b39690b5b97beda492b4f50a4d94857fae43a68a7ae60195526766a83b99851 |
|
MD5 | ec2ec70cedc46e52143b5cc13efe712f |
|
BLAKE2b-256 | c1a585af7d25a6a3b200e99dacb783f382534bcfd1a44a7231d2ece4c9da80a2 |
Close
Hashes for docx_replace_attach-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65309800a99e40b7a7923af4f6aa78a7d14c8131bfb298e69a7a892f18a4ceae |
|
MD5 | 7fbc91031740652e7fc27fd363b6a0b3 |
|
BLAKE2b-256 | cbc56688a068092cb3578025d170191f1a4348a1c87ba94a5d65068fb1c12131 |