Currently the gtsave
function in the gt
package does not support MS-Word
. I tried converting a gt
object to a flextable
object to then save as word, but flextable doesn't support a gt object. And when I just copy paste an html
to Word, the aesthetics are lost. And a PNG is not ideal either, as when I resize the picture, the font size does not match the document font size. Is there a workaround this?
# Download package
devtools::install_github("rstudio/gt")
# Load package
library(gt)
# Code
gt_tbl = gt(head(mtcars), caption = 'This is table caption') %>%
tab_header(title="Some Title", subtitle="Table 1: Mtcars with gt."
# Export the table
# As word
library(flextable)
gt_tbl %>%
flextable::as_flextable() %>%
flextable::save_as_docx(path = "~")
Error
Error in UseMethod("as_flextable") :
no applicable method for 'as_flextable' applied to an object of class "c('gt_tbl', 'list')"