<style> block and a Shadow DOM wrapper to isolate table styles from the rest of the page.
Save to an HTML file
save_as_html() writes one or more flextable objects to a standalone HTML file. Named objects produce <h2> section headings above each table:
| Parameter | Description | Default |
|---|---|---|
... | flextable objects, optionally named | |
values | Named list of flextable objects (alternative to ...) | NULL |
path | Output file path ending in .html | |
title | HTML page <title> | " " |
lang | IETF language tag for the <html lang> attribute | "en" |
Use in Shiny with htmltools_value()
htmltools_value() returns a tagList containing the table HTML and its CSS dependencies. Use it inside renderUI() in Shiny:
ft.align argument:
Scrollable tables
For large tables, enable scrolling withset_table_properties():
div with overflow-y: auto and a fixed height. You can also freeze the first column:
ft.htmlscroll chunk option to enable horizontal scrolling without calling set_table_properties():
CSS customization
Useset_flextable_defaults(extra_css = ...) to inject additional CSS into every table rendered in the session:
set_table_properties():
HTML dependencies
flextable HTML output depends on a bundled CSS file (tabwid.css). When embedding flextable output in custom htmltools-based pages, retrieve the dependency objects with:
htmltools::htmlDependency objects that you can attach to your own tags using htmltools::attachDependencies().