Add flextable into layout placeholder
phl_with_flextable(x, olay, id, value)rpptx object
an OfficerLayout object created using phl_layout.
an single integer with an id of the placeholder from olay object.
a flextable object.
Possibly the result of the phl_adjust_table
rpptx object which represents PowerPoint presentation in officer. The returned object contains a new element on the slide.
library(officer)
lay <- lay_new(matrix(1:4,nc=2),widths=c(3,2),heights=c(2,1))
lay2 <- lay_new(matrix(1:3))
lay3 <- lay_bind_col(lay,lay2, widths=c(3,1))
offLayout <- phl_layout(lay3)
pptx <- read_pptx()
pptx <- add_slide(
pptx,
master = "Office Theme",
layout = "Title and Content"
)
# add table to pptx file
x <- tail(iris, 10)[,c(1,5)]
xf <- phl_adjust_table(x, offLayout, 1)
pptx <- phl_with_flextable(pptx, offLayout, 1, xf)
x2 <- tail(iris, 10)[,c(1,5)]
xf2 <- phl_adjust_table(x, offLayout, 2)
pptx <- phl_with_flextable(pptx, offLayout, 2, xf2)
if(interactive()) {
file <- tempfile(fileext = ".pptx")
print(pptx, target = file)
}