1

When I print a flextable to a word document the cell alignment vertically is defaulted to centered, but I'm wondering if there's a way to make the text sit at the bottom of the cell.

I am aware of the flextable::align() function, but it only applies to horizontal alignment. Does anyone know a way of changing the default vertical alignment?

Sample code:

 read_docx() %>% 
   body_add_flextable(value = iris %>% regulartable()) %>%
   print("Test.docx")
morgan121
  • 2,213
  • 1
  • 15
  • 33

1 Answers1

2

You need to use function style, there is no shortcut for that property.

library(flextable)
library(magrittr)
library(officer)

ft <- iris %>% 
  regulartable() %>% 
  style(pr_c = fp_cell(vertical.align = "bottom")) %>% 
  theme_booktabs() %>% # as style will replace all existing style...
  height_all(height = .5) # make height bigger to see the bottom alignt.

read_docx() %>% 
  body_add_flextable(value = ft ) %>%
  print("Test.docx") 
David Gohel
  • 9,180
  • 2
  • 16
  • 34
  • Awesome thanks :) Also I've asked a number of flextable questions and you always provide a solution fairly quickly, so thanks for that too :) – morgan121 Dec 11 '18 at 21:48