Automatically Generate Multiple Slides Using a Certificate PPT Template
Starting from this course, we will perform step-by-step tasks that can be applied in real-world scenarios based on the knowledge we've accumulated so far.
Let's assume a situation where you need to generate multiple slides
for certificates in a PowerPoint template, based on training completion information
downloaded as an Excel file.
Reading the Excel data line by line and pasting it into the PowerPoint template manually is extremely inefficient.
We can automate such repetitive tasks using Python.
Excel Data and Certificate Project
First, we will get the information to be included in the certificates from an Excel file.
The Excel file contains the number, name, and rank of the graduates.
For example, let's assume we use the following data:
Example Excel Data
No. | Name | Grade |
---|---|---|
1 | John Doe | A |
2 | Jane Roe | B |
3 | Sam Smith | A |
4 | Chris Lee | C |
5 | Alex Kim | B |
Based on this data, we will generate pptx slides reflecting the information for each certificate.
Loading the Excel File
First, load the data from the Excel file using the openpyxl library, as shown in the code below.
import openpyxl # Load the Excel file workbook = openpyxl.load_workbook('input_file.xlsx') sheet = workbook.active # Print Excel data for row in sheet.iter_rows(min_row=2, values_only=True): # Skip the header row print(row)
When you run the above code, you will sequentially print the number, name, and grade from the Excel file.
('Award', 'John Doe', 'For outstanding performance and dedicated efforts, we present this award.', 'August 23, 2024', 'CodeFriends') ('Excellence', 'Jane Roe', 'For diligent efforts and consistent performance, we present this award.', 'August 24, 2024', 'CodeFriends') ('Merit', 'Sam Smith', 'For creative ideas and new approaches, we present this award.', 'August 25, 2024', 'CodeFriends') ('Merit', 'Chris Lee', 'For creative ideas and new approaches, we present this award.', 'August 4, 2024', 'CodeFriends') ('Excellence', 'Alex Kim', 'For diligent efforts and consistent performance, we present this award.', 'August 5, 2024', 'CodeFriends')
Lecture
AI Tutor
Publish
Design
Upload
Notes
Favorites
Help
Code Editor
Execution Result