Skip to contents

This function allows you to update the underlying styling for your xlr_table. This changes how the titles, footnotes, columns, and body objects look when you write you xlr_table to excel with write_xlsx().

Usage

update_theme(
  x,
  title_format = xlr_format(font_size = 12, text_style = "bold"),
  footnote_format = xlr_format(font_size = 9, text_style = "italic"),
  column_heading_format = xlr_format(font_size = 11, text_style = "bold", border =
    c("top", "bottom"), halign = "center", wrap_text = TRUE),
  table_body_format = xlr_format(border = c("top", "left", "right", "bottom"))
)

Arguments

x

a xlr_table

title_format

a xlr_format object to format the title

footnote_format

a xlr_format object to format the footnote

column_heading_format

a xlr_format object to format the column heading

table_body_format

a xlr_format object to format the body

Value

Returns a xlr_table object.

Details

If you want to change the style of the columns in the data, you should convert them to a xlr_vector, xlr_numeric, xlr_integer or xlr_percent type if they are not already, and then update the xlr_format attribute, by setting the style parameter.

Examples

library(xlr)
# set up a basic table
bt <- xlr_table(mtcars,
                 "A title",
                 "A footnote")
# now we want to update the title
# This changes what it look likes when we print it to excel
bt <- update_theme(bt,
                   xlr_format(font_size = 12,
                               text_style = c("bold","underline")))
if (FALSE) { # \dontrun{
write_xlsx(bt,
           "example.xlsx",
           "Test")} # }