PivotOpenXlsxStyles: R6 class that defines a collection of Excel styles as used by...

PivotOpenXlsxStylesR Documentation

R6 class that defines a collection of Excel styles as used by the openxlsx package.

Description

The 'PivotOpenXlsxStyles' class stores a collection of 'PivotOpenXlsxStyle' style objects.

Format

R6Class object.

Active bindings

count

The number of 'PivotOpenXlsxStyle' objects in this 'PivotOpenXlsxStyles' collection.

styles

A list containing the 'PivotOpenXlsxStyle' objects in this 'PivotOpenXlsxStyles' collection.

Methods

Public methods


Method new()

Create a new 'PivotOpenXlsxStyles' object.

Usage
PivotOpenXlsxStyles$new(parentPivot)
Arguments
parentPivot

The pivot table that this 'PivotOpenXlsxStyles' instance belongs to.

Returns

A new 'PivotOpenXlsxStyles' object.


Method clearStyles()

Clear the internal list of styles.

Usage
PivotOpenXlsxStyles$clearStyles()
Returns

No return value.


Method findNamedStyle()

Find an existing openxlsx style matching the name of a base style.

Usage
PivotOpenXlsxStyles$findNamedStyle(baseStyleName)
Arguments
baseStyleName

The name of the base style to find.

Returns

A 'PivotOpenXlsxStyle' object with the specified name.


Method findOrAddStyle()

Find an existing openxlsx style, add a new openxlsx style matching a base style and/or existing 'PivotStyle' object.

Usage
PivotOpenXlsxStyles$findOrAddStyle(
  action = "findOrAdd",
  baseStyleName = NULL,
  isBaseStyle = NULL,
  style = NULL,
  mapFromCss = TRUE
)
Arguments
action

Must be one of "find" (to search for an existing style), "add" (to add a new style) or "findOrAdd" (default, to first search for an existing style, and if no match is found then add a new style)

baseStyleName

The name of the base style to find.

isBaseStyle

'TRUE' if the style being sought is a base style.

style

An existing 'PivotStyle' object.

mapFromCss

Default 'TRUE', to create a new 'PivotOpenXlsxStyle' by mapping from CSS style declarations.

Details

This function is used in two different ways: (1) When adding base styles (i.e. named styles in the pivot table) to this 'PivotOpenXlsxStyles' collection: In this case, 'baseStyleName' is the name of the style and 'isBaseStyle=TRUE' (so matching is by name only) and 'style' is the 'PivotStyle' object for the base style. (2) When finding styles that have been applied to individual cells using the 'PivotStyle' object that is attached to each cell: In this case, 'baseStyleName' may or may not be present, 'isBaseStyle=FALSE' and 'style' is the 'PivotStyle' object from the cell.

Returns

A 'PivotOpenXlsxStyle' object that has been found or added.


Method addNamedStyles()

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

Usage
PivotOpenXlsxStyles$addNamedStyles(mapFromCss = TRUE)
Arguments
mapFromCss

Default 'TRUE', to create a new 'PivotOpenXlsxStyle' by mapping from CSS style declarations.

Returns

No return value.


Method asList()

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

Usage
PivotOpenXlsxStyles$asList()
Returns

A list of various object properties.


Method asJSON()

Return the contents of this object as JSON for debugging.

Usage
PivotOpenXlsxStyles$asJSON()
Returns

A JSON representation of various object properties.


Method asString()

Return a representation of this object as a character value.

Usage
PivotOpenXlsxStyles$asString(seperator = ", ")
Arguments
seperator

A character value used when concatenating multiple styles.

Returns

A character summary of various object properties.


Method clone()

The objects of this class are cloneable with this method.

Usage
PivotOpenXlsxStyles$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

# This class should only be created by the pivot table.
# It is not intended to be created outside of the pivot table.

pivottabler documentation built on Oct. 1, 2023, 5:07 p.m.