| TableOpenXlsxStyle {basictabler} | R Documentation | 
R6 class that specifies Excel styling as used by the openxlsx package.
Description
The 'TableOpenXlsxStyle' class specifies the styling for cells in an Excel worksheet.
Format
R6Class object.
Active bindings
baseStyleNameThe name of the base style in the table.
isBaseStyle'TRUE' when this style is the equivalent of a named style in the table, 'FALSE' if this style has additional settings over and above the base style of the same name.
fontNameThe name of the font (single font name, not a CSS style list).
fontSizeThe size of the font (units: point).
boldTRUE' if text is bold.
italic'TRUE' if text is italic.
underline'TRUE' if text is underlined.
strikethrough'TRUE' if text has a line through it.
superscript'TRUE' if text is small and raised.
subscript'TRUE' if text is small and lowered.
fillColorThe background colour for the cell (as a hex value, e.g. #00FF00).
textColorThe color of the text (as a hex value).
hAlignThe horizontal alignment of the text: left, center or right.
vAlignThe vertical alignment of the text: top, middle or bottom.
wrapTextTRUE if the text is allowed to wrap onto multiple lines.
textRotationThe rotation angle of the text or 255 for vertical.
indentThe text indentation.
borderAllA list (with elements style and color) specifying the border settings for all four sides of each cell at once.
borderLeftA list (with elements style and color) specifying the border settings for the left border of each cell.
borderRightA list (with elements style and color) specifying the border settings for the right border of each cell.
borderTopA list (with elements style and color) specifying the border settings for the top border of each cell.
borderBottomA list (with elements style and color) specifying the border settings for the bottom border of each cell.
valueFormatThe Excel formatting applied to the field value. One of the following values: "GENERAL", "NUMBER", "CURRENCY", "ACCOUNTING", "DATE", "LONGDATE", TIME, "PERCENTAGE", "FRACTION", "SCIENTIFIC", "TEXT", "COMMA". Or for dates/datetimes, a combination of d, m, y. Or for numeric values, use 0.00 etc.
minColumnWidthThe minimum width of this column.
minRowHeightThe minimum height of this row.
openxlsxStyleThe return value from openxlsx::createStyle().
Methods
Public methods
Method new()
Create a new 'TableOpenXlsxStyle' object.
Usage
TableOpenXlsxStyle$new( parentTable, baseStyleName = NULL, isBaseStyle = NULL, fontName = NULL, fontSize = NULL, bold = NULL, italic = NULL, underline = NULL, strikethrough = NULL, superscript = NULL, subscript = NULL, fillColor = NULL, textColor = NULL, hAlign = NULL, vAlign = NULL, wrapText = NULL, textRotation = NULL, indent = NULL, borderAll = NULL, borderLeft = NULL, borderRight = NULL, borderTop = NULL, borderBottom = NULL, valueFormat = NULL, minColumnWidth = NULL, minRowHeight = NULL )
Arguments
parentTableOwning table.
baseStyleNameThe name of the base style in the table.
isBaseStyle'TRUE' when this style is the equivalent of a named style in the table, 'FALSE' if this style has additional settings over and above the base style of the same name.
fontNameThe name of the font (single font name, not a CSS style list).
fontSizeThe size of the font (units: point).
bold'TRUE' if text is bold.
italic'TRUE' if text is italic.
underline'TRUE' if text is underlined.
strikethrough'TRUE' if text has a line through it.
superscript'TRUE' if text is small and raised.
subscript'TRUE' if text is small and lowered.
fillColorThe background colour for the cell (as a hex value, e.g. #00FF00).
textColorThe color of the text (as a hex value).
hAlignThe horizontal alignment of the text: left, center or right.
vAlignThe vertical alignment of the text: top, middle or bottom.
wrapText'TRUE' if the text is allowed to wrap onto multiple lines.
textRotationThe rotation angle of the text or 255 for vertical.
indentThe text indentation.
borderAllA list (with elements style and color) specifying the border settings for all four sides of each cell at once.
borderLeftA list (with elements style and color) specifying the border settings for the left border of each cell.
borderRightA list (with elements style and color) specifying the border settings for the right border of each cell.
borderTopA list (with elements style and color) specifying the border settings for the top border of each cell.
borderBottomA list (with elements style and color) specifying the border settings for the bottom border of each cell.
valueFormatThe Excel formatting applied to the field value. One of the following values: "GENERAL", "NUMBER", "CURRENCY", "ACCOUNTING", "DATE", "LONGDATE", TIME, "PERCENTAGE", "FRACTION", "SCIENTIFIC", "TEXT", "COMMA". Or for dates/datetimes, a combination of d, m, y. Or for numeric values, use 0.00 etc.
minColumnWidthThe minimum width of this column.
minRowHeightThe minimum height of this row.
Returns
No return value.
Method isBasicStyleNameMatch()
Check if this style matches the specified base style name.
Usage
TableOpenXlsxStyle$isBasicStyleNameMatch(baseStyleName = NULL)
Arguments
baseStyleNameThe style name to compare to.
Returns
'TRUE' if the style name matches, 'FALSE' otherwise.
Method isFullStyleDetailMatch()
Check if this style matches the specified style properties.
Usage
TableOpenXlsxStyle$isFullStyleDetailMatch( baseStyleName = NULL, isBaseStyle = NULL, fontName = NULL, fontSize = NULL, bold = NULL, italic = NULL, underline = NULL, strikethrough = NULL, superscript = NULL, subscript = NULL, fillColor = NULL, textColor = NULL, hAlign = NULL, vAlign = NULL, wrapText = NULL, textRotation = NULL, indent = NULL, borderAll = NULL, borderLeft = NULL, borderRight = NULL, borderTop = NULL, borderBottom = NULL, valueFormat = NULL, minColumnWidth = NULL, minRowHeight = NULL )
Arguments
baseStyleNameThe style name to compare to.
isBaseStyleWhether the style being compared to is a base style.
fontNameThe font name to compare to.
fontSizeThe font size to compare to.
boldThe style property bold to compare to.
italicThe style property italic to compare to.
underlineThe style property underline to compare to.
strikethroughThe style property strikethrough to compare to.
superscriptThe style property superscript to compare to.
subscriptThe style property subscript to compare to.
fillColorThe style property fillColor to compare to.
textColorThe style property textColor to compare to.
hAlignThe style property hAlign to compare to.
vAlignThe style property vAlign to compare to.
wrapTextThe style property wrapText to compare to.
textRotationThe style property textRotation to compare to.
indentThe style property indent to compare to.
borderAllThe style property borderAll to compare to.
borderLeftThe style property borderLeft to compare to.
borderRightThe style property borderRight to compare to.
borderTopThe style property borderTop to compare to.
borderBottomThe style property borderBottom to compare to.
valueFormatThe style value format to compare to.
minColumnWidthThe style property minColumnWidth to compare to.
minRowHeightThe style property minRowHeight to compare to.
Returns
'TRUE' if the style matches, 'FALSE' otherwise.
Method createOpenXslxStyle()
Create the 'openxlsx' style based on the specified style properties.
Usage
TableOpenXlsxStyle$createOpenXslxStyle()
Returns
No return value.
Method asList()
Return the contents of this object as a list for debugging.
Usage
TableOpenXlsxStyle$asList()
Returns
A list of various object properties.
Method asJSON()
Return the contents of this object as JSON for debugging.
Usage
TableOpenXlsxStyle$asJSON()
Returns
A JSON representation of various object properties.
Method asString()
Return the contents of this object as a string for debugging.
Usage
TableOpenXlsxStyle$asString()
Returns
A character representation of various object properties.
Method clone()
The objects of this class are cloneable with this method.
Usage
TableOpenXlsxStyle$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
# This class should only be created by using the functions in the table.
# It is not intended to be created by users outside of the table.
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.