The `FlexTableRenderer` class creates a representation of a table using the `flextable` package. See the Output vignette for more details.

Format

R6Class object.

Methods

Public methods


Method new()

Create a new `FlexTableRenderer` object.

Usage

FlexTableRenderer$new(parentTable)

Arguments

parentTable

Owning table.

Returns

No return value.


Method writeToCell()

Write a value to a cell, optionally with styling and cell merging.

Usage

FlexTableRenderer$writeToCell(
  ft = NULL,
  rowNumber = NULL,
  columnNumber = NULL,
  totalRowCount = NULL,
  totalColumnCount = NULL,
  value = NULL,
  applyStyles = TRUE,
  baseStyleName = NULL,
  style = NULL,
  mapFromCss = TRUE,
  mergeRows = NULL,
  mergeColumns = NULL
)

Arguments

ft

The flextable to write to.

rowNumber

The row number of the cell where the value is to be written.

columnNumber

The column number of the cell where the value is to be written.

value

The value to be written. Since the flextable is created from a data frame, this argument can be omitted.

applyStyles

`TRUE` (default) to also set the styling of the cell, `FALSE` to only write the value.

baseStyleName

The name of the style from the table theme to apply to the cell.

style

A `TableStyle` object that contains additional styling to apply to the cell.

mapFromCss

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

mergeRows

If the cell is to be merged with adjacent cells, then an integer or numeric vector specifying the row numbers of the merged cell. NULL (default) to not merge cells.

mergeColumns

If the cell is to be merged with adjacent cells, then an integer or numeric vector specifying the column numbers of the merged cell. NULL (default) to not merge cells.

Returns

The updated flextable definition.


Method writeBorder()

Write the borders of a cell.

Usage

FlexTableRenderer$writeBorder(
  ft = NULL,
  rowNumber = NULL,
  columnNumber = NULL,
  totalRowCount = NULL,
  totalColumnCount = NULL,
  border = NULL,
  borderLeft = NULL,
  borderRight = NULL,
  borderTop = NULL,
  borderBottom = NULL
)

Arguments

ft

The flextable to write to.

rowNumber

The row number of the cell where the border is to be written.

columnNumber

The column number of the cell where the border is to be written.

totalRowCount

The total number of rows in the table.

totalColumnCount

The total number of columns in the table.

border

The border to be applied to all sides of the cell (unless a border is specified using the other arguments).

borderLeft

The border to apply to the left side of the cell.

borderRight

The border to apply to the right side of the cell.

borderTop

The border to apply to the top side of the cell.

borderBottom

The border to apply to the bottom side of the cell.

Returns

The updated flextable definition.


Method asFlexTable()

Convert table to a flextable table.

Usage

FlexTableRenderer$asFlexTable(applyStyles = TRUE, mapStylesFromCSS = TRUE)

Arguments

applyStyles

`TRUE` (default) to also set the styling of the cells, `FALSE` to only write the value.

mapStylesFromCSS

`TRUE` (default) to map the basictabler CSS styles to corresponding flextable styles where possible, `FALSE` to apply only the specified ft styles.

Returns

No return value.


Method clone()

The objects of this class are cloneable with this method.

Usage

FlexTableRenderer$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 converting to a # flextable.