R/TableOpenXlsxRenderer.R
TableOpenXlsxRenderer.RdThe `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)
parentTableOwning 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 )
wbA workbook object from the openxlsx package.
wsNameThe name of the worksheet where the value is to be written.
rowNumberThe row number of the cell where the value is to be written.
columnNumberThe column number of the cell where the value is to be written.
valueThe value to be written.
applyStyles`TRUE` (default) to also set the styling of the cell, `FALSE` to only write the value.
baseStyleNameThe name of the style from the table theme to apply to the cell.
styleA `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.
mergeRowsIf 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.
mergeColumnsIf 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 )
wbA workbook object from the openxlsx package.
wsNameThe name of the worksheet where the value is to be written.
topRowNumberThe row number of the top-left cell where the table is to be written.
leftMostColumnNumberThe column number of the top-left cell where the table is to be written.
outputValuesAsSpecify 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)
deepWhether 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.