| write_xlsx | R Documentation |
Exports a data frame or a list of data frames to one or multiple Excel files,
with support for titles, subtitles, source notes, footnotes, grouping, and custom styles.
It leverages the openxlsx package to create styled Excel reports suitable for presentation.
write_xlsx(
data,
path,
...,
sheet_name = NULL,
title = NULL,
subtitle = NULL,
source_note = NULL,
footnotes = NULL,
separate_files = FALSE,
collapse_list = FALSE,
row_group_as_column = FALSE,
names_separator = "__",
include_table_list = FALSE,
table_list_reference = NULL,
facade = get_tsg_facade()
)
data |
A
|
path |
A file path (if |
... |
Additional arguments passed to |
sheet_name |
Optional name for the Excel sheet. Ignored if |
title |
Optional title displayed above the data in each sheet or file. |
subtitle |
Optional subtitle displayed under the title. |
source_note |
Optional source note displayed below the data. |
footnotes |
Optional character vector of footnotes to display below the source note. |
separate_files |
Logical. If |
collapse_list |
Logical. If |
row_group_as_column |
Logical. If |
names_separator |
Character used to separate column names when dealing with nested or grouped headers. |
include_table_list |
Logical. If |
table_list_reference |
A data frame containing the table list reference. If |
facade |
A list of styling options (colors, fonts, sizes, border styles, etc.). Defaults to the global option |
This function supports advanced Excel formatting including:
Grouped headers
Dynamic column widths
Styled titles, subtitles, source notes, and footnotes
Border styling (inner, outer, header)
The function is designed to handle export needs in professional and reporting contexts.
Invisibly returns NULL. The function is called for its side-effect of writing Excel file(s).
data <- tsg::generate_frequency(dplyr::starwars, sex)
dir_to <- tempfile()
write_xlsx(
data,
file.path(dir_to, "starwars_frequency.xlsx")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.