Python E化-自动生成PPT
from pptx import Presentation
from pptx.util import Pt
import pptx
import openpyxl
file_address=r'D:\Python_E\others\auto_PPT\2020.5.14单机版V1\\'
prs = Presentation(file_address+'公司PPT:input-WT.pptx')
wb=openpyxl.load_workbook(file_address+'data.xlsx')
sheet=wb.get_sheet_by_name('整理文章')
slide = prs.slides[0]
slide.shapes.title.text = sheet.cell(row=1, column=1).value
tf = slide.shapes.placeholders[1].text_frame
tf.text = sheet.cell(row=1, column=2).value
tf.font= Pt(15)
slide = prs.slides[1]
slide.shapes.title.text = sheet.cell(row=2, column=1).value
tf = slide.shapes.placeholders[1].text_frame
tf.text=''
p = tf.add_paragraph()
p.text = sheet.cell(row=2, column=2).value
p.font.size = Pt(20)
p.level = 1
for j in range(3,11+1):
bullet_slide_layout = prs.slide_layouts[1]
slide = prs.slides.add_slide(bullet_slide_layout)
slide.shapes.title.text = sheet.cell(row=j, column=1).value
tf = slide.shapes.placeholders[1].text_frame
p = tf.add_paragraph()
p.text = sheet.cell(row=j, column=2).value
p.font.size = Pt(16)
p.level = 1
prs.save(file_address+'公司PPT:output3.pptx')
print('OK')