R/TableOpenXlsxRenderer.R
TableOpenXlsxRenderer.Rd
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.
R6Class
object.
new()
Create a new `TableOpenXlsxRenderer` object.
TableOpenXlsxRenderer$new(parentTable)
parentTable
Owning table.
No return value.
writeToCell()
Write a value to a cell, optionally with styling and cell merging.
TableOpenXlsxRenderer$writeToCell( wb = NULL, wsName = NULL, rowNumber = NULL, columnNumber = NULL, value = NULL, applyStyles = TRUE, baseStyleName = NULL, style = NULL, mapFromCss = TRUE, mergeRows = NULL, mergeColumns = NULL )
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.
No return value.
writeToWorksheet()
Write a table to an Excel worksheet.
TableOpenXlsxRenderer$writeToWorksheet( wb = NULL, wsName = NULL, topRowNumber = NULL, leftMostColumnNumber = NULL, outputValuesAs = "rawValue", useFormattedValueIfRawValueIsNull = TRUE, applyStyles = TRUE, mapStylesFromCSS = TRUE )
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.
No return value.
clone()
The objects of this class are cloneable with this method.
TableOpenXlsxRenderer$clone(deep = FALSE)
deep
Whether to make a deep clone.
# 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.