Skip to contents

Export a SimtablR table to a Word (.docx) file

Usage

export_docx(x, path, footnotes = NULL, methods = FALSE, overwrite = FALSE, ...)

Arguments

x

A SimtablR object with an as_flextable() method (e.g. from table1() or tb()).

path

Output file path. A missing .docx suffix is added; any other suffix is rejected.

footnotes

Optional character vector passed to table renderers that support footnotes.

methods

Logical; when TRUE, append recorded as_methods() prose after the exported table(s).

overwrite

Logical. Existing files are protected by default; pass TRUE to replace the destination explicitly.

...

Passed to flextable::save_as_docx() (e.g. page properties).

Value

Invisibly returns the normalized output path.

Details

Exports are written to a temporary file in the destination directory and published only after the backend succeeds. Existing files are never changed unless overwrite = TRUE.

Examples

if (FALSE) { # \dontrun{
data(epitabl)
table1(epitabl, c("age", "sex"), by = "adjudicated_acs") |>
  export_docx(tempfile(fileext = ".docx"))
} # }