# Example data frame
my_data <- dummy_data(1000)
# Define style
set_style_options(column_widths = c(2, 15, 15, 15, 9))
# Define titles and footnotes. If you want to add hyperlinks you can do so by
# adding "link:" followed by the hyperlink to the main text.
set_titles("This is title number 1 link: https://cran.r-project.org/",
"This is title number 2",
"This is title number 3")
set_footnotes("This is footnote number 1",
"This is footnote number 2",
"This is footnote number 3 link: https://cran.r-project.org/")
# Print styled data frame
my_data |> export_with_style()
# Retrieve formatted workbook for further usage
wb <- my_data |> export_with_style()
# To save a table as xlsx file you have to set the path and filename in the
# style element
# Example files paths
table_file <- tempfile(fileext = ".xlsx")
# Note: Normally you would directly input the path ("C:/MyPath/") and name ("MyFile.xlsx").
set_style_options(save_path = dirname(table_file),
file = basename(table_file),
sheet_name = "MyTable")
my_data |> export_with_style()
# Manual cleanup for example
unlink(table_file)
# Global options are permanently active until the current R session is closed.
# There are also functions to reset the values manually.
reset_style_options()
reset_qol_options()
close_file()
Run the code above in your browser using DataLab