prs = Presentation((path_to_presentation))
# text_runs will be populated with a list of strings,
# one for each text run in presentation
text_runs = []
for slide in prs.slides:
for shape in slide.shapes:
if not shape.has_table:
continue
tbl = shape.table
row_count = len(tbl.rows)
col_count = len(tbl.columns)
for r in range(0, row_count):
for c in range(0, col_count):
cell = tbl.cell(r,c)
paragraphs = cell.text_frame.paragraphs
for paragraph in paragraphs:
for run in paragraph.runs:
text_runs.append(run.text)
print(text_runs)```
totable(t.test(wt ~ am, mtcars), filename = file.path(tempdir(), "mtcars.pptx"))
## inpptx and indocx provide function read the tables in pptx or docx
tabs <- inpptx(filename = file.path(tempdir(), "mtcars.pptx"), header = TRUE)
3条答案
按热度按时间odopli941#
希望this能为你工作。但是,代码是用Python编写的。你可以很容易地修改为R。
uqxowvwt2#
请尝试在CRAN上发布的软件包eoffice并使用inpptx函数:
kq4fsx7k3#
要在R中将PowerPoint转换为PDF,您可以考虑以下方法:
要从PowerPoint中提取表格,可以考虑以下方法: