Set different options which define the visual output of 'Excel' tables produced
by frequencies(), crosstabs() and any_table().
excel_output_style(
save_path = NULL,
file = NULL,
sheet_name = "Table",
font = "Arial",
column_widths = "auto",
row_heights = "auto",
title_heights = NULL,
header_heights = NULL,
subheader_heights = NULL,
table_heights = NULL,
footnote_heights = NULL,
start_row = 2,
start_column = 2,
freeze_col_header = FALSE,
freeze_row_header = FALSE,
filters = TRUE,
grid_lines = TRUE,
by_as_subheaders = FALSE,
header_back_color = "FFFFFF",
header_font_color = "000000",
header_font_size = 10,
header_font_bold = TRUE,
header_alignment = "center",
header_wrap = "1",
header_indent = 0,
header_borders = TRUE,
header_border_color = "000000",
subheader_back_color = "FFFFFF",
subheader_font_color = "000000",
subheader_font_size = 10,
subheader_font_bold = TRUE,
subheader_alignment = "center",
subheader_wrap = "1",
subheader_indent = 0,
subheader_borders = TRUE,
subheader_border_color = "000000",
cat_col_back_color = "FFFFFF",
cat_col_font_color = "000000",
cat_col_font_size = 10,
cat_col_font_bold = FALSE,
cat_col_alignment = "left",
cat_col_wrap = "1",
cat_col_indent = 1,
cat_col_borders = TRUE,
cat_col_border_color = "000000",
table_back_color = "FFFFFF",
table_font_color = "000000",
table_font_size = 10,
table_font_bold = FALSE,
table_alignment = "right",
table_indent = 1,
table_borders = FALSE,
table_border_color = "000000",
as_heatmap = FALSE,
heatmap_low_color = "F8696B",
heatmap_middle_color = "FFFFFF",
heatmap_high_color = "63BE7B",
box_back_color = "FFFFFF",
box_font_color = "000000",
box_font_size = 10,
box_font_bold = TRUE,
box_alignment = "center",
box_wrap = "1",
box_indent = 0,
box_borders = TRUE,
box_border_color = "000000",
number_formats = number_format_style(),
title_font_color = "000000",
title_font_size = 10,
title_font_bold = TRUE,
title_alignment = "left",
footnote_font_color = "000000",
footnote_font_size = 8,
footnote_font_bold = FALSE,
footnote_alignment = "left",
na_symbol = "."
)Returns a list of named style options.
If NULL, opens the output as temporary file. Otherwise specify an output path.
If NULL, opens the output as temporary file. Otherwise specify a filename with extension.
Name of the sheet inside the workbook to which the output shall be written. If multiple outputs are produced in one go, the sheet name additionally receives a running number.
Set the font to be used for the entire output.
Specify whether column widths should be set automatically and individually or if a numeric vector is passed each column width can be specified manually. If a table has more columns than column widths are provided, the last given column width will be repeated until the end of the table.
Specify whether row heights should be set automatically and individually or if a numeric vector is passed each row height can be specified manually. If a table has more rows than row heights are provided, the last given row height will be repeated until the end of the table.
Set individual row heights for the titles only.
Set individual row heights for the table header only.
Set individual row heights for the table subheader only.
Set individual row heights for the table body only.
Set individual row heights for the footnotes only.
The row in which the table starts.
The column in which the table starts.
Whether to freeze the column header so that it is always visible while scrolling down the document.
Whether to freeze the row header so that it is always visible while scrolling sideways in the document.
Whether to set filters in the column header, when exporting a data frame.
Whether to show grid lines or not.
Whether to format by variables as subheaders in one table instead of single tables on multiple sheets.
Background cell color of the table header.
Font color of the table header.
Font size of the table header.
Whether to print the table header in bold letters.
Set the text alignment of the table header.
Whether to wrap the texts in the table header.
Indentation level of the table header.
Whether to draw borders around the table header cells.
Borders colors of the table header cells.
Background cell color of the table subheader.
Font color of the table subheader.
Font size of the table subheader.
Whether to print the table subheader in bold letters.
Set the text alignment of the table subheader.
Whether to wrap the texts in the table subheader.
Indentation level of the table subheader.
Whether to draw borders around the table subheader cells.
Borders colors of the table subheader cells.
Background cell color of the category columns inside the table.
Font color of the category columns inside the table.
Font size of the category columns inside the table.
Whether to print the category columns inside the table in bold letters.
Set the text alignment of the category columns inside the table.
Whether to wrap the texts in the category columns inside the table.
Indentation level of the category columns inside the table.
Whether to draw borders around the category columns inside the table.
Borders colors of the category columns inside the table.
Background color of the inner table cells.
Font color of the inner table cells.
Font size of the inner table cells.
Whether to print the inner table cells in bold numbers
Set the text alignment of the inner table cells.
Indentation level of the inner table cells.
Whether to draw borders around the inner table cells.
Borders colors of the inner table cells.
Whether to lay a conditional formatting over the values.
The color for lower values in the conditional formatting.
The color for middle values in the conditional formatting.
The color for high values in the conditional formatting.
Background color of the left box in table header.
Font color of the left box in table header.
Font size of the left box in table header.
Whether to print the left box in table header in bold letters.
Set the text alignment of the left box in table header.
Whether to wrap the texts in the left box in table header.
Indentation level of the left box in table header.
Whether to draw borders around the left box in table header.
Borders colors of the left box in table header.
Put in a list of number formats which should be assigned to
the different stats. Number formats can be created with number_format_style().
Font color of the titles.
Font size of the tables titles.
Whether to print the tables titles in bold letters.
Set the text alignment of the titles.
Font color of the footnotes
Font size of the tables footnotes
Whether to print the tables footnotes in bold letters.
Set the text alignment of the footnotes.
Define the symbol that should be used for NA values.
excel_output_style() is based on the Output Delivery System (ODS) in 'SAS',
which provides efficient and readable ways to set up different table styles.
With the output style you have full control over the table design. There is no need to think about calculating the right place to input a background color or a border of a certain type and how to do this in a loop for multiple cells. Just input colors, borders, font styles, etc. for the different table parts and everything else is handled by the functions capable of using styles.
The concept basically is: design over complex calculations.
Creating a custom table style: modify_output_style(),
number_format_style(), modify_number_formats().
Global style options: set_style_options(), set_variable_labels(), set_stat_labels().
Functions that can handle styles: frequencies(), crosstabs(), any_table(),
export_with_style()
# For default values
excel_style <- excel_output_style()
# Set specific options, the rest will be set to default values
excel_style <- excel_output_style(font = "Calibri",
sheet_name = "My_Output")
# For cells with no background color pass an empty string
excel_style <- excel_output_style(table_back_color = "")
Run the code above in your browser using DataLab