The `TableOpenXlsxRenderer` class creates a representation of a table in an Excel file using the `openxlsx` package. See the Excel Output vignette for more details.

Format

R6Class object.

Methods

Public methods


Method new()

Create a new `TableOpenXlsxRenderer` object.

Usage

TableOpenXlsxRenderer$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

TableOpenXlsxRenderer$writeToCell(
  wb = NULL,
  wsName = NULL,
  rowNumber = NULL,
  columnNumber = NULL,
  value = NULL,
  applyStyles = TRUE,
  baseStyleName = NULL,
  style = NULL,
  mapFromCss = TRUE,
  mergeRows = NULL,
  mergeColumns = NULL
)

Arguments

wb

A workbook object from the openxlsx package.

wsName

The name of the worksheet where the value is to be written.

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.

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

No return value.


Method writeToWorksheet()

Write a table to an Excel worksheet.

Usage

TableOpenXlsxRenderer$writeToWorksheet(
  wb = NULL,
  wsName = NULL,
  topRowNumber = NULL,
  leftMostColumnNumber = NULL,
  outputValuesAs = "rawValue",
  useFormattedValueIfRawValueIsNull = TRUE,
  applyStyles = TRUE,
  mapStylesFromCSS = TRUE
)

Arguments

wb

A workbook object from the openxlsx package.

wsName

The name of the worksheet where the value is to be written.

topRowNumber

The row number of the top-left cell where the table is to be written.

leftMostColumnNumber

The column number of the top-left cell where the table is to be written.

outputValuesAs

Specify whether the raw or formatted values should be written to the worksheet. Value must be one of "rawValue", "formattedValueAsText", "formattedValueAsNumber".

useFormattedValueIfRawValueIsNull

`TRUE` to use the formatted cell value instead of the raw cell value if the raw value is `NULL`. `FALSE` to always use the raw value. Default `TRUE`.

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 Excel styles, `FALSE` to apply only the specified xl styles.

Returns

No return value.


Method clone()

The objects of this class are cloneable with this method.

Usage

TableOpenXlsxRenderer$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# This class is for internal use only. It is # created only by the BasicTable class 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.