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
Built Distribution
File details
Details for the file docx-replace-attach-0.0.1.tar.gz
.
File metadata
- Download URL: docx-replace-attach-0.0.1.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e862b793dab1d53898b5b1251a163e4f86366926738a601c46e6e54c6250982 |
|
MD5 | e86c905609017d5723b56a1479b3d582 |
|
BLAKE2b-256 | 6d06d7cd6b7e3ab8d5e886f7c39ecc3a0cf7ecf641b30ce2505d5a13019ddf09 |
File details
Details for the file docx_replace_attach-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: docx_replace_attach-0.0.1-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2456f2cba70249cdddaf77a24472c3cb1e7659941cb7991cf9cbae7b4793be3 |
|
MD5 | 44268d2a5027d4cddbae34dfbb1502dd |
|
BLAKE2b-256 | dfff3430c6b006c682522ffbd99acd5a2d52bb1d16ab896dee6e525df550c3cd |