我有一台新计算机(阅读:所有内容的新版本,包括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")
...现在,在我的新电脑上,标题的行高没有被翻译成Word文档。dim(control_table)提供了正确的行高,但word文档中未显示标题行高。我遗漏了什么?
发布于 2020-08-19 17:52:52
Word不处理旋转标题的自动高度,因此有必要使用函数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")

https://stackoverflow.com/questions/63236245
复制相似问题