python package for replaceing elemnets in pptx files
Project description
pptx-replace
A python package for replaceing text, images and tables in pptx files
import pptx
import pptx_replace
prs = Presentation("tests/templates/test_template.pptx")
replace_text(prs, "{Main title}", "this is main report title")
slide = prs.slides[1]
replace_text(slide, "{title}", "This is a title")
replace_picture(prs.slides[0], "image.png", auto_reshape=True)
installation
pip install pptx-replace
If you want to put altair
picture into pptx file, you need install some extra packages.
pip install "pptx-replace[alt]"
see: https://github.com/altair-viz/altair_saver
extra dependency
Depends on your usage, if you want to export table and keep style in jupyter, selemium
and browser driver is required.
see: https://github.com/dexplo/dataframe_image/
usage
First open your pptx file.
import pptx
import pptx_replace
prs = Presentation("tests/templates/test_template.pptx")
replace picture
Replace picture just by matplotlib figuer!
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
fig = plt.gcf()
replace_picture(prs.slides[1], fig, auto_reshape=False, order="l2r")
replace table
replace table by pandas dataframe
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.rand(6, 10))
replace_table(slide, df)
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
pptx-replace-0.1.tar.gz
(13.8 MB
view hashes)
Built Distribution
Close
Hashes for pptx_replace-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99164e9cbc78d935b31218736c2acc942fa41414567ba17dde95c74d1affd9d3 |
|
MD5 | d4ed7a92cb12a0187b6b1526fc5b3206 |
|
BLAKE2b-256 | b800aaa5ea7d9213ba4b727ab87ff1e34ec0f8290da6b899ad38eb7840a8cc48 |