Replace key words to attachments inside a document of MS Word or Excel
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.
Just like this:
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
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.4.tar.gz
.
File metadata
- Download URL: docx_replace_attach-0.0.4.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee4186e37a6f27f7bcdc322165e4c22725c331e0d4a6238d67a924d10584e625 |
|
MD5 | 707e2ee31512e669f8df13dd47b11d83 |
|
BLAKE2b-256 | f8e0b8bd2e2cda49c1e2e92f9c55232ea5af2c69f075c11a2bc4cd1e2590dda2 |
File details
Details for the file docx_replace_attach-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: docx_replace_attach-0.0.4-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bad15314a2c525e482f4d1f30bec540c77f1f762ff89170f86d8515bf4b5277 |
|
MD5 | 1941e5236f75e97b37be5dcdd7fcfde9 |
|
BLAKE2b-256 | 3509c89373b070c9d605cf9e6a70cf54961a967340a0dfac44d8f0c820a1aa61 |