5.3 Exporting

To export our table to MS Word (.docx), we may use the officer package. This package simplifies working with various Microsoft Office formats and integrates nicely with flextable.

library(officer)

# send the flextable to .docx output
read_docx() %>%
  body_add_flextable(my_flextable) %>%
  print(target = "my_document.docx")

In your working directory, you should now see the file my_document.docx has been created and contains your table.