导出 ppt 时图像未显示在 flextable 行中
Image not displayed in row of flextable on export ppt
我正在尝试将具有图片行的柔性表格导出到 powerpoint,但在生成的 powerpoint 上没有显示。
但是它在 R studio Viewer 上运行良好。
请问您知道问题出在哪里吗?
提前致谢
library(kableExtra)
library(flextable)
library(officer)
doc <- read_pptx()
img.file <- file.path( R.home("doc"), "html", "logo.jpg" )
myft <- flextable( head(mtcars),
col_keys = c("am", "separator", "gear", "mpg", "drat", "qsec" ))
myft <- compose( myft, i = ~ qsec > 18, j = "qsec",
value = as_paragraph(as_image( src = img.file, width = .20, height = .15))
)
myft <- autofit(myft)
myft
doc <- add_slide(doc)
doc <- ph_with(doc, value = myft, location = ph_location_template(top = 2, width = 4, type = "body"))
print(doc, target = "./cars.pptx")
system2('cmd', args = c('/c', '"./cars.pptx"'))
PowerPoint 无法做到这一点,您可以在此处阅读文档:https://davidgohel.github.io/flextable/articles/display.html#limitation-for-powerpoint-1
Using images in flextable is not supported when output format is PowerPoint. This is not a choice nor an unimplemented feature. This is because PowerPoint is not able to embed images in a table cell. That’s a PowerPoint limitation.
我正在尝试将具有图片行的柔性表格导出到 powerpoint,但在生成的 powerpoint 上没有显示。
但是它在 R studio Viewer 上运行良好。
请问您知道问题出在哪里吗?
提前致谢
library(kableExtra)
library(flextable)
library(officer)
doc <- read_pptx()
img.file <- file.path( R.home("doc"), "html", "logo.jpg" )
myft <- flextable( head(mtcars),
col_keys = c("am", "separator", "gear", "mpg", "drat", "qsec" ))
myft <- compose( myft, i = ~ qsec > 18, j = "qsec",
value = as_paragraph(as_image( src = img.file, width = .20, height = .15))
)
myft <- autofit(myft)
myft
doc <- add_slide(doc)
doc <- ph_with(doc, value = myft, location = ph_location_template(top = 2, width = 4, type = "body"))
print(doc, target = "./cars.pptx")
system2('cmd', args = c('/c', '"./cars.pptx"'))
PowerPoint 无法做到这一点,您可以在此处阅读文档:https://davidgohel.github.io/flextable/articles/display.html#limitation-for-powerpoint-1
Using images in flextable is not supported when output format is PowerPoint. This is not a choice nor an unimplemented feature. This is because PowerPoint is not able to embed images in a table cell. That’s a PowerPoint limitation.