构建融合服务门户中的PPTX处理
pip install openpyxl
import openpyxl
from pptx import Presentation
def read_pptx(file_path):
presentation = Presentation(file_path)
for slide in presentation.slides:
for shape in slide.shapes:
if hasattr(shape, "text"):
print(shape.text)
# 使用函数
read_pptx('example.pptx')
import openpyxl
from pptx import Presentation
def read_and_write_pptx(file_path, excel_path):
presentation = Presentation(file_path)
wb = openpyxl.Workbook()
ws = wb.active
row = 1
for slide in presentation.slides:
for shape in slide.shapes:
if hasattr(shape, "text"):
ws.cell(row=row, column=1, value=shape.text)
row += 1
wb.save(excel_path)
# 使用函数
read_and_write_pptx('example.pptx', 'output.xlsx')
本站知识库部分内容及素材来源于互联网,如有侵权,联系必删!