View source: R/class-workbook-wrappers.R
| wb_add_style | R Documentation |
The wb_add_style() function serves as a general-purpose entry point for
registering XML-based style definitions into a wbWorkbook. While specific
wrappers like wb_add_font() target individual cell properties, wb_add_style()
is used to add pre-constructed styles—such as custom table styles or
differential formatting (DXF) styles—to the workbook's internal style manager.
wb_add_style(wb, style = NULL, style_name = NULL)
wb |
A wbWorkbook object. |
style |
A character string containing the XML definition of the style.
This is usually the output of functions like |
style_name |
Optional; a unique name for the style. If |
Styles in the OpenXML specification are stored in a centralized catalog
(styles.xml). This function takes an XML character string, typically
generated by a create_*() function, and registers it under a specific
style_name.
Once registered, these styles can be applied to cells, ranges, or tables by referencing their name. This is particularly useful for maintaining consistency across a large workbook or when creating complex "Table Styles" that define headers, footers, and banding in a single object.
The wbWorkbook object, invisibly.
If the style provided is a tableStyle node, the function automatically
extracts the name from the XML attribute if style_name is not provided.
Registering a style does not automatically apply it to a cell; it only makes the style available within the workbook's style catalog.
create_border()
create_cell_style()
create_dxfs_style()
create_fill()
create_font()
create_numfmt()
Other workbook styling functions:
base_font-wb,
wb_add_dxfs_style(),
wb_base_colors
yellow_f <- wb_color(hex = "FF9C6500")
yellow_b <- wb_color(hex = "FFFFEB9C")
yellow <- create_dxfs_style(font_color = yellow_f, bg_fill = yellow_b)
wb <- wb_workbook()
wb <- wb_add_style(wb, yellow)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.