Skip to main content
save_as_html() saves one or more flextable objects to a self-contained HTML file. This is useful for sharing or previewing tables outside of R Markdown. R Markdown is recommended for production documents.

Function signature

save_as_html(..., values = NULL, path, lang = "en", title = " ")

Parameters

...
flextable
required
One or more flextable objects, optionally named. Named objects use the name as a title above the table.
values
list
A list of flextable objects (optionally named). If supplied, ... is ignored.
path
string
required
Path to the .html file to create.
lang
string
default:"en"
Language of the HTML document, specified as an IETF language tag (e.g., "en", "fr", "de").
title
string
default:" "
HTML page title shown in the browser tab.

Return value

A string containing the full path of the generated file.

Examples

Save a single table:
ft <- flextable(head(iris))
tf <- tempfile(fileext = ".html")
if (rmarkdown::pandoc_available()) {
  save_as_html(ft, path = tf)
}
Save multiple named tables with a custom page title:
ft1 <- flextable(head(iris))
ft2 <- flextable(head(mtcars))
tf <- tempfile(fileext = ".html")
if (rmarkdown::pandoc_available()) {
  save_as_html(
    `iris table`   = ft1,
    `mtcars table` = ft2,
    path  = tf,
    title = "My tables"
  )
}

See also