phl_with_flextable: Add flextable into layout placeholder

Description Usage Arguments Value Examples

View source: R/flextable.R

Description

Add flextable into layout placeholder

Usage

1
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

Value

rpptx object which represents PowerPoint presentation in officer. The returned object contains a new element on the slide.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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)
}

zzawadz/customLayout documentation built on June 9, 2021, 11:10 a.m.