I want to automate the creation of PowerPoint slides with one certificate per student per slide. To do this I take the student names from an excel spreadsheet and put them in an existing PowerPoint. I have, for example, 100 students and therefore, I need 100 different certificates in my PowerPoint. Here's what I've done so far:
from pptx import Presentation
import pandas as pd
dataframe = pd.read_excel('normal.xlsx')
prs = Presentation('C:\\Users\\xyz\\Desktop\\demo.pptx')
repl_str_u = 'Jhon cena'
repl_str_y = 'Dec-2019'
repl_str_l = 'Tom curze'
users = []
for i in dataframe['Nominee Name']:
users.append(i)
x = len(users)
Manager = []
for i in dataframe['LPM']:
Manager.append(i)
Month = []
for i in dataframe['Period']:
Month.append(i)
for slide in prs.slides:
for shape in slide.shapes:
if shape.has_text_frame:
for i in range(x):
shape.text = shape.text.replace(search_str_username, users[i])
shape.text = shape.text.replace(search_str_formonth, Month[i])
shape.text = shape.text.replace(search_str_lpm, Manager[i])
prs.save('C:\\Users\\suraj\\Desktop\\op.pptx')