我已经起草了一些数据框,里面有文本,每个单元格中都有换行符,数据框被转换为 flextable
然后插入到powerpoint幻灯片中,使用 officer
. 我发现线的高度有点过高,我试着使用了 height_all
作用于 flextable
来减少行高,但却没有效果。请看下面的示例代码。
library(officer)
library(dplyr)
pptx.output.st00 <- read_pptx()
data(iris)
data.df <- head(iris) %>%
as_tibble %>%
mutate_all(.,as.character) %>%
mutate_all(.,~paste0(.,'\ntesting'))
pptx.tbl <- data.df %>%
flextable %>%
height_all(height = 0.01) # this line is not working
pptx.output.st01 <- pptx.output.st00 %>%
add_slide(.,layout = 'Title and Content',master = 'Office Theme') %>%
ph_with(.,value=pptx.tbl,location=ph_location(type='body'))
print(pptx.output.st01,'presentation.output.pptx')
目前我需要手动更改表格的段落设置,如下图所示。
有没有一种方法在 officer
的 flextable
来设置桌子的线高?谢谢!我起草了一些数据框,里面有文本,每个单元格中都有换行符,数据框转换为flextable,然后插入Powerpoint幻灯片中。
我并不满意这个临时的方式,但。padding(padding.top = 0, padding.bottom = 0.5)
和 height_all(0.45)
给予更好的输出。
pptx.output.st01 <- pptx.output.st00 %>%
add_slide(.,layout = 'Title and Content',master = 'Office Theme') %>%
ph_with(.,
value=pptx.tbl %>%
padding(padding.top = 0, padding.bottom = 0.5) %>%
height_all(0.45),
location=ph_location(type='body'))