Learn R Programming

openxlsx2 (version 0.8)

wb_base_font: Get / set the default font in a workbook

Description

Modify / get the default font for the workbook.

Usage

wb_set_base_font(
  wb,
  font_size = 11,
  font_color = wb_color(theme = "1"),
  font_name = "Calibri",
  ...
)

wb_get_base_font(wb)

Arguments

wb

A workbook object

font_size

font size

font_color

font color

font_name

Name of a font

...

additional arguments

Details

The font name is not validated in anyway. Excel replaces unknown font names with Arial. Base font is black, size 11, Calibri.

See Also

Other workbook wrappers: wb_add_chartsheet(), wb_add_data_table(), wb_add_data(), wb_add_formula(), wb_add_pivot_table(), wb_add_worksheet(), wb_clone_worksheet(), wb_col_widths, wb_copy_cells(), wb_creators, wb_freeze_pane(), wb_grouping, wb_merge_cells(), wb_save(), wb_set_last_modified_by(), wb_set_row_heights(), wb_workbook()

Examples

Run this code
## create a workbook
wb <- wb_workbook()
wb$add_worksheet("S1")
## modify base font to size 10 Arial Narrow in red
wb$set_base_font(fontSize = 10, fontColor = "#FF0000", fontName = "Arial Narrow")

wb$add_data("S1", iris)
wb$add_data_table("S1", x = iris, startCol = 10) ## font color does not affect tables

## get the base font
## create a workbook
wb <- wb_workbook()
wb_get_base_font(wb)

## modify base font to size 10 Arial Narrow in red
wb$set_base_font(fontSize = 10, fontColor = "#FF0000", fontName = "Arial Narrow")

wb_get_base_font(wb)

Run the code above in your browser using DataLab