customLayout (version 0.3.0)

phl_with_flextable: add flextable into layout placeholder

Description

add flextable into layout placeholder

Usage

phl_with_flextable(x, olay, id, value)

Arguments

x

rpptx object

olay

an OfficerLayout object created using phl_layout.

id

an single integer with an id of the placeholder from olay object.

value

a flextable object. Possibly the result of the phl_adjust_table

Examples

Run this code
# NOT RUN {
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)

# }
# NOT RUN {
file <- tempfile(fileext = ".pptx")
print(pptx, target = file)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab