【问题标题】:flextable Header Border with border.right argument带有border.right参数的flextable页眉边框
【发布时间】:2020-05-12 02:32:57
【问题描述】:

我正在尝试在标题的两侧放置垂直边框,并且能够为左侧而不是右侧获得边框。

library(officer)
library(flextable)
library(dplyr)
bigborder <- fp_border(style = "solid", width=2)
flextable(head(iris)) %>%
  add_header_row(top = TRUE, values = c("12", "3", "45"), colwidths = c(2,1, 2)) %>%
  add_header_row(top = TRUE, values = c("123", "45"), colwidths = c(3, 2)) %>%
  border(border.left = bigborder, j = 1, part = "all") %>%
  border(border.right= bigborder, j = 5, part = "all")

【问题讨论】:

    标签: r flextable officer


    【解决方案1】:

    这是一个示例或在标题部分设置垂直边框:

    library(officer)
    library(flextable)
    library(magrittr)
    bigborder <- fp_border(style = "solid", width=2)
    thinborder <- fp_border(color="gray", width=.5)
    flextable(head(iris)) %>% 
      add_header_row(top = TRUE, values = c("12", "3", "45"), colwidths = c(2,1, 2)) %>%
      add_header_row(top = TRUE, values = c("123", "45"), colwidths = c(3, 2)) %>%
      border_remove() %>% 
      vline(border = thinborder, part = "header") %>%
      vline_left(border = bigborder, part = "header") %>%
      vline_right(border = bigborder, part = "header") %>% 
      align(align = "center", part = "header") %>% 
      fix_border_issues()
    

    【讨论】:

    • 太好了,谢谢,看起来像在末尾添加fix_border_issues() 可以修复我的代码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多