具有 flextable 和 officer 的行高

Row heigth with flextable and officer

我有一台新电脑(阅读:所有内容的新版本,包括 Office 2016) 我在以前的计算机上创建了以下代码,并且一切正常:

...
control_table <- regulartable(data = data) %>%
  theme_box() %>%
  rotate(rotation = "btlr", part = "header") %>%
  align(align = "left", part = "body") %>% 
  set_header_labels(Var1 = " " ) %>% 
  align(align = "left", part = "header") %>%
  height(height = 3, part = "header") %>%
  width(width = 0.3) %>%
  width(j = 1, width = 3.5) 

doc <- doc %>%
  cursor_reach("The following table indicates the reports") %>%
  body_add_flextable(control_table, align = "left")
...

现在在我的新电脑上,header 的行高没有被转换成 Word 文档。 dim(control_table) 给出了正确的行高,但是 header 行高没有显示在 word 文档中。 我错过了什么?

Word 不支持自动旋转高度 headers,因此需要使用函数 hrule.

指定行高规则
library(flextable)
library(officer)
library(magrittr)

control_table <- flextable(data = head(iris)) %>%
  theme_box() %>%
  rotate(rotation = "btlr", part = "header") %>%
  align(align = "left", part = "body") %>% 
  set_header_labels(Var1 = " " ) %>% 
  align(align = "left", part = "header") %>%
  height(height = 2, part = "header") %>%
  hrule(i = 1, rule = "exact", part = "header")


doc <- read_docx() %>%
  body_add_flextable(control_table, align = "left") %>% 
  print(target = "example.docx")