The `TableOpenXlsxStyles` class stores a collection of `TableTableOpenXlsx` style objects.

Format

R6Class object.

Active bindings

count

The number of styles in the collection.

styles

A list of `TableOpenXlsxStyle` objects that comprise the collection.

Methods

Public methods


Method new()

Create a new `TableOpenXlsxStyles` object.

Usage

TableOpenXlsxStyles$new(parentTable)

Arguments

parentTable

Owning table.

Returns

No return value.


Method clearStyles()

Clear the collection removing all styles.

Usage

TableOpenXlsxStyles$clearStyles()

Returns

No return value.


Method findNamedStyle()

Find a style in the collection matching the specified base style name.

Usage

TableOpenXlsxStyles$findNamedStyle(baseStyleName)

Arguments

baseStyleName

The style name to find.

Returns

A `TableTableOpenXlsx` object that is the style matching the specified base style name or `NULL` otherwise.


Method findOrAddStyle()

Find a style in the collection matching the specified base style name and style properties. If there is no matching style, then optionally add a new style.

Usage

TableOpenXlsxStyles$findOrAddStyle(
  action = "findOrAdd",
  baseStyleName = NULL,
  isBaseStyle = NULL,
  style = NULL,
  mapFromCss = TRUE
)

Arguments

action

The action to carry out. Must be one of "find", "add" or "findOrAdd" (default).

baseStyleName

The style name to find/add.

isBaseStyle

Is the style to be found/added a base style?

style

A `TableStyle` object specifying style properties to be found/added.

mapFromCss

`TRUE` (default) to map the basictabler CSS styles to corresponding Excel styles, `FALSE` to apply only the specified xl styles.

Returns

A `TableTableOpenXlsx` object that is the style matching the specified base style name or `NULL` otherwise.


Method addNamedStyles()

Populate the OpenXlsx styles based on the styles defined in the table.

Usage

TableOpenXlsxStyles$addNamedStyles(mapFromCss = TRUE)

Arguments

mapFromCss

`TRUE` (default) to map the basictabler CSS styles to corresponding Excel styles, `FALSE` to apply only the specified xl styles.

Returns

No return value.


Method asList()

Return the contents of this object as a list for debugging.

Usage

TableOpenXlsxStyles$asList()

Returns

A list of various object properties.


Method asJSON()

Return the contents of this object as JSON for debugging.

Usage

TableOpenXlsxStyles$asJSON()

Returns

A JSON representation of various object properties.


Method asString()

Return the contents of this object as a string for debugging.

Usage

TableOpenXlsxStyles$asString(seperator = ", ")

Arguments

seperator

Delimiter used to combine multiple values into a string.

Returns

A character representation of various object properties.


Method clone()

The objects of this class are cloneable with this method.

Usage

TableOpenXlsxStyles$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# This class should not be used by end users. It is an internal class # created only by the BasicTable class. It is used when rendering to Excel. library(basictabler) tbl <- qtbl(data.frame(a=1:2, b=3:4)) library(openxlsx) wb <- createWorkbook(creator = Sys.getenv("USERNAME")) addWorksheet(wb, "Data") tbl$writeToExcelWorksheet(wb=wb, wsName="Data", topRowNumber=1, leftMostColumnNumber=1, applyStyles=TRUE, mapStylesFromCSS=TRUE) # Use saveWorkbook() to save the Excel file.