Using Loops In Python-pptx To Create Multiple Slides And Writing Dataframe To Slides
I have the below code for creating ppt out of dataframes: Below is a snippet of the code for 3 slides: title_slide_layout = prs.slide_layouts[1] slide = prs.slides.add_slide(title_
Solution 1:
This is what functions are for, to abstract some repetative task down to a (function) call:
defadd_slide(prs, layout, title):
"""Return slide newly added to `prs` using `layout` and having `title`."""
slide = prs.slides.add_slide(layout)
slide.shapes.title.text = title
return slide
title_slide_layout = prs.slide_layouts[1]
slide = add_slide(prs, title_slide_layout, "Summary Table")
slide2 = add_slide(prs, title_slide_layout, "New Table")
slide3 = add_slide(prs, title_slide_layout, "Old Table")
Your second question is an entirely different question and I recommend you ask it separately. StackOverflow is designed around a one-question-at-a-time format.
Post a Comment for "Using Loops In Python-pptx To Create Multiple Slides And Writing Dataframe To Slides"