I've made a flextable with various formatting, but when I add to the PowerPoint, the table is outside the slide size.
I'm not sure if I have to just go through and set the column & row sizes, or if there is something I should set up in my PowerPoint template master settings. I saw where you can set column and row sizes, but nothing about the overall flextable dimensions.
Code below.
library(officer)
library(rvg)
library(flextable)
library(tidyverse)
library(data.table)
pColor <- "#3c5cb0"
std_border = fp_border(color="gray")
outSatTbl <- flextable(head(iris, 19))
outSatTbl <-
outSatTbl %>%
bg(bg = pColor, part = "header") %>%
color(color = "white", part = "header") %>%
merge_h(part = "header") %>%
add_header_lines(values = "Demo Table") %>%
align(align = "center", part = "header") %>%
align(align = "center", part = "body") %>%
hline(part="body", border = std_border ) %>%
autofit()
# ---------- Get PowerPoint template and initiate ---------- #
setwd("C:/.../WorkingFolder")
demo <- read_pptx("Rtest.pptx")
# ---------- Add Inpatient table to Power Point ----------- #
demo <- add_slide(demo , layout = "Title and Content", master = "Theme1") %>%
ph_with(outSatTbl, location = ph_location_type(type = "body"), use_loc_size = T) %>%
print(mho, target = "first_example.pptx")
This makes the table too big. I can resize it and the table still looks great, just trying to find what I'm missing.