#' Add Flextable to New Slide
#'
#' @param .slide powerpoint slide
#' @param .flex flextable
#' @param .layout character
#' @param .master character
#'
#' @return powerpoint slide
#' @export
#'
#'
add_flex_to_new_slide <- function(slide,
flex,
layout,
master = "Office Theme") {
f_list <- list(flex)
officer::add_slide(slide, layout, master)
slide <- move_to_current_slide(slide)
## get slide details
s_det <- get_layout_details(slide, layout, master)
s_det <- s_det[s_det$type == "tbl", ]
s_det <- s_det[order(s_det$ph_label), ]
tbls_to_add <- max(length(f_list), nrow(s_det))
## add tables
for (i in 1:tbls_to_add) {
fx <- f_list[[1]]
from_left <- flex_center_h(slide, fx, layout, s_det$ph_label[[i]])
from_top <- flex_center_v(slide, fx, layout, s_det$ph_label[[i]])
flextable::ph_with_flextable_at(slide, fx, from_left, from_top)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.