Skip to content

Instantly share code, notes, and snippets.

@samirsaci
Created September 17, 2022 13:14
Show Gist options
  • Select an option

  • Save samirsaci/5d313947e7cb664698828232f3cf9b08 to your computer and use it in GitHub Desktop.

Select an option

Save samirsaci/5d313947e7cb664698828232f3cf9b08 to your computer and use it in GitHub Desktop.
Automate PPT
'''Slides Analysis per Week'''
for WEEK in LIST_WEEKS:
# Create Plot
avg_ratio, max_ratio, busy_day, max_lines, total_lines = analysis_week(df_day, WEEK)
# Create a slide
slide = prs.slides.add_slide(image_slide_layout)
shapes = slide.shapes
# Create Title
title_shape = shapes.title
title_shape.text = 'Warehouse Workload ({})'.format(WEEK)
# Add Image
left = Inches(0.75)
top = Inches(1.25)
pic = slide.shapes.add_picture('{}.png'.format(WEEK), left, top, height=Inches(4.5))
# Build the Text Box
left = Inches(0.75)
top = Inches(1.5) + Inches(4)
width = Inches(9)
height = Inches(2)
txBox = slide.shapes.add_textbox(left, top, width, height)
tf = txBox.text_frame
# Title
p = tf.add_paragraph()
p.text = 'Analysis'
p.font.size = Pt(18)
# First bullet point
p = tf.add_paragraph()
p.text = '• {} have been prepared during the week'.format(total_lines)
p.level = 1
# Second bullet point
p = tf.add_paragraph()
p.text = '• {} has been the busiest day with {} prepared'.format(busy_day, max_lines)
p.level = 1
# Third bullet point
p = tf.add_paragraph()
p.text = '• {} on average with a maximum of {}'.format(avg_ratio, max_ratio)
p.level = 1
# Add Pages
txBox = slide.shapes.add_textbox(Inches(9), Inches(6.75), Inches(1), Inches(1))
tf = txBox.text_frame
p = tf.add_paragraph()
p.text = str('{}/{}'.format(page, len(LIST_WEEKS) + 1 ))
p.font.size = Pt(15)
page += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment