Learn R Programming

flextable (version 0.10.0)

save_as_docx: Save flextable objects in a 'Word' file

Description

sugar function to save flextable objects in an Word file.

Usage

save_as_docx(..., values = NULL, path, pr_section = NULL, align = "center")

Value

a string containing the full name of the generated file

Arguments

...

flextable objects, objects, possibly named. If named objects, names are used as titles.

values

a list (possibly named), each element is a flextable object. If named objects, names are used as titles. If provided, argument ... will be ignored.

path

Word file to be created

pr_section

a officer::prop_section object that can be used to define page layout such as orientation, width and height.

align

left, center (default) or right.

See Also

paginate()

Other functions for flextable output and export: df_printer(), flextable_to_rmd(), gen_grob(), htmltools_value(), knit_print.flextable(), plot.flextable(), print.flextable(), repair_docx(), save_as_html(), save_as_image(), save_as_pptx(), save_as_rtf(), to_html.flextable(), wrap_flextable()

Examples

Run this code

tf <- tempfile(fileext = ".docx")

library(officer)
ft1 <- flextable(head(iris))
save_as_docx(ft1, path = tf)


ft2 <- flextable(head(mtcars))
sect_properties <- prop_section(
  page_size = page_size(
    orient = "landscape",
    width = 8.3, height = 11.7
  ),
  type = "continuous",
  page_margins = page_mar()
)
save_as_docx(
  `iris table` = ft1, `mtcars table` = ft2,
  path = tf, pr_section = sect_properties
)

Run the code above in your browser using DataLab