ruby语言读取PPT中文本框和表格内容
ppt = WIN32OLE::new('powerpoint.Application')
ppt.DisplayAlerts = 1 #不显示任何警告
ppt_presents = ppt.Presentations #演示文稿
present = ppt_presents.open(filename,false,false,true)
for slide in present.Slides
for shape in slide.shapes
if (shape.TextFrame.HasText == -1)
begin
text = shape.TextFrame.TextRange.Text ##按文本框读取PPT内容
rescue
##抛出异常情况,比如文本框叠加等
end
elsif (shape.Type == 19) ##按表格读取PPT内容
row = shape.Table.Rows.count
column = shape.Table.columns.count
for m in 1..row
for n in 1..column
text_table = shape.Table.Cell(m,n).Shape.TextFrame.TextRange.text
end
end
end
end
end
present.Save
present.Close
ppt.quit