R6 class for a Workbook
R6 class for a Workbook
The integer position of the sheet
The wbWorkbook object
The wbWorkbook object
The wbWorkbook object
A named
character vector of sheet names in their order. The
names represent the original value of the worksheet prior to any
character substitutions.
The wbWorkbook object
The wbWorkbook object
The wbWorkbook object
The wbWorkbook object
The wbWorkbook object
The wbWorkbook object
The wbWorkbook object
The sheet tables. character() if empty
The wbWorkbook object
The wbWorkbook object
The wbWorkbook object
The wbWorkbook object
The wbWorkbook object
The wbWorkbook object
Returns sheet visibility
The wbWorkbook object
The wbWorkbook object
a character vector of cell styles
sheet_namessheet_names
calcChaincalcChain
appsapps
chartscharts
isChartSheetisChartSheet
connectionsconnections
Content_TypesContent_Types
appapp
corecore
drawingsdrawings
drawings_relsdrawings_rels
embeddingsembeddings
externalLinksexternalLinks
externalLinksRelsexternalLinksRels
headFootheadFoot
mediamedia
metadatametadata
personspersons
pivotTablespivotTables
pivotTables.xml.relspivotTables.xml.rels
pivotDefinitionspivotDefinitions
pivotRecordspivotRecords
pivotDefinitionsRelspivotDefinitionsRels
queryTablesqueryTables
rowHeightsrowHeights
slicersslicers
slicerCachesslicerCaches
sharedStringssharedStrings
styles_mgrstyles_mgr
styles_xmlstyles_xml
tablestables
tables.xml.relstables.xml.rels
themetheme
vbaProjectvbaProject
vmlvml
vml_relsvml_rels
commentscomments
threadCommentsthreadComments
workbookworkbook
workbook.xml.relsworkbook.xml.rels
worksheetsworksheets
worksheets_relsworksheets_rels
sheetOrderThe sheet order. Controls ordering for worksheets and worksheet names.
pathpath
creatorA character vector of creators
titletitle
subjectsubject
categorycategory
datetimeCreatedThe datetime (as POSIXt) the workbook is
created. Defaults to the current Sys.time() when the workbook object
is created, not when the Excel files are saved.
new()Creates a new wbWorkbook object
wbWorkbook$new(
creator = NULL,
title = NULL,
subject = NULL,
category = NULL,
datetimeCreated = Sys.time()
)creatorcharacter vector of creators. Duplicated are ignored.
titletitle
subjectsubject
categorycategory
datetimeCreatedThe datetime (as POSIXt) the workbook is
created. Defaults to the current Sys.time() when the workbook object
is created, not when the Excel files are saved.
a wbWorkbook object
append()Append a field. This method is intended for internal use
wbWorkbook$append(field, value)fieldA valid field name
valueA value for the field
append_sheets()Append to self$workbook$sheets This method is intended for internal use
wbWorkbook$append_sheets(value)valueA value for self$workbook$sheets
validate_sheet()validate sheet
wbWorkbook$validate_sheet(sheet)sheetA character sheet name or integer location
add_worksheet()Add worksheet to the wbWorkbook object
wbWorkbook$add_worksheet(
sheet = next_sheet(),
gridLines = TRUE,
rowColHeaders = TRUE,
tabColour = NULL,
zoom = 100,
header = NULL,
footer = NULL,
oddHeader = header,
oddFooter = footer,
evenHeader = header,
evenFooter = footer,
firstHeader = header,
firstFooter = footer,
visible = c("true", "false", "hidden", "visible", "veryhidden"),
hasDrawing = FALSE,
paperSize = getOption("openxlsx2.paperSize", default = 9),
orientation = getOption("openxlsx2.orientation", default = "portrait"),
hdpi = getOption("openxlsx2.hdpi", default = getOption("openxlsx2.dpi", default = 300)),
vdpi = getOption("openxlsx2.vdpi", default = getOption("openxlsx2.dpi", default = 300))
)sheetsheet
gridLinesgridLines
rowColHeadersrowColHeaders
tabColourtabColour
zoomzoom
headerheader
footerfooter
oddHeaderoddHeader
oddFooteroddFooter
evenHeaderevenHeader
evenFooterevenFooter
firstHeaderfirstHeader
firstFooterfirstFooter
visiblevisible
hasDrawinghasDrawing
paperSizepaperSize
orientationorientation
hdpihdpi
vdpivdpi
The wbWorkbook object, invisibly
clone_worksheet()Clone a workbooksheet
wbWorkbook$clone_worksheet(old = current_sheet(), new = next_sheet())oldname of worksheet to clone
newname of new worksheet to add
addChartSheet()Add a chart sheet to the workbook
wbWorkbook$addChartSheet(sheet = current_sheet(), tabColour = NULL, zoom = 100)sheetsheet
tabColourtabColour
zoomzoom
The wbWorkbook object, invisibly
add_data()add data
wbWorkbook$add_data(
sheet = current_sheet(),
x,
startCol = 1,
startRow = 1,
dims = rowcol_to_dims(startRow, startCol),
array = FALSE,
xy = NULL,
colNames = TRUE,
rowNames = FALSE,
withFilter = FALSE,
name = NULL,
sep = ", ",
applyCellStyle = TRUE,
removeCellStyle = FALSE,
na.strings
)sheetsheet
xx
startColstartCol
startRowstartRow
dimsdims
arrayarray
xyxy
colNamescolNames
rowNamesrowNames
withFilterwithFilter
namename
sepsep
applyCellStyleapplyCellStyle
removeCellStyleif writing into existing cells, should the cell style be removed?
na.stringsna.strings
returnThe wbWorkbook object
add_data_table()add a data table
wbWorkbook$add_data_table(
sheet = current_sheet(),
x,
startCol = 1,
startRow = 1,
dims = rowcol_to_dims(startRow, startCol),
xy = NULL,
colNames = TRUE,
rowNames = FALSE,
tableStyle = "TableStyleLight9",
tableName = NULL,
withFilter = TRUE,
sep = ", ",
firstColumn = FALSE,
lastColumn = FALSE,
bandedRows = TRUE,
bandedCols = FALSE,
applyCellStyle = TRUE,
removeCellStyle = FALSE,
na.strings
)sheetsheet
xx
startColstartCol
startRowstartRow
dimsdims
xyxy
colNamescolNames
rowNamesrowNames
tableStyletableStyle
tableNametableName
withFilterwithFilter
sepsep
firstColumnfirstColumn
lastColumnlastColumn
bandedRowsbandedRows
bandedColsbandedCols
applyCellStyleapplyCellStyle
removeCellStyleif writing into existing cells, should the cell style be removed?
na.stringsna.strings
add_formula()add formula
wbWorkbook$add_formula(
sheet = current_sheet(),
x,
startCol = 1,
startRow = 1,
dims = rowcol_to_dims(startRow, startCol),
array = FALSE,
xy = NULL,
applyCellStyle = TRUE,
removeCellStyle = FALSE
)sheetsheet
xx
startColstartCol
startRowstartRow
dimsdims
arrayarray
xyxy
applyCellStyleapplyCellStyle
removeCellStyleif writing into existing cells, should the cell style be removed?
add_style()add style
wbWorkbook$add_style(style = NULL, style_name = NULL)stylestyle
style_namestyle_name
pathThe path to save the workbook to
overwriteIf FALSE, will not overwrite when path exists
The wbWorkbook object invisibly
interactiveIf FALSE will throw a warning and not open the path.
This can be manually set to TRUE, otherwise when NA (default) uses
the value returned from base::interactive()
The wbWorkbook, invisibly
buildTable()Build table
wbWorkbook$buildTable(
sheet = current_sheet(),
colNames,
ref,
showColNames,
tableStyle,
tableName,
withFilter,
totalsRowCount = 0,
showFirstColumn = 0,
showLastColumn = 0,
showRowStripes = 1,
showColumnStripes = 0
)sheetsheet
colNamescolNames
refref
showColNamesshowColNames
tableStyletableStyle
tableNametableName
withFilterwithFilter
totalsRowCounttotalsRowCount
showFirstColumnshowFirstColumn
showLastColumnshowLastColumn
showRowStripesshowRowStripes
showColumnStripesshowColumnStripes
The wbWorksheet object, invisibly
get_base_font()Get the base font
wbWorkbook$get_base_font()A list of of the font
set_base_font()Get the base font
wbWorkbook$set_base_font(
fontSize = 12,
fontColour = wb_colour(theme = "1"),
fontName = "Calibri"
)fontSizefontSize
fontColourfontColour
fontNamefontName
The wbWorkbook object
get_sheet_names()Get sheet names
wbWorkbook$get_sheet_names()
set_sheet_names()Sets a sheet name
wbWorkbook$set_sheet_names(old = NULL, new)oldOld sheet name
newNew sheet name
The wbWorkbook object, invisibly
setSheetName()Deprecated. Use set_sheet_names() instead
wbWorkbook$setSheetName(sheet = current_sheet(), name)sheetOld sheet name
nameNew sheet name
The wbWorkbook object, invisibly
set_row_heights()Sets a row height for a sheet
wbWorkbook$set_row_heights(sheet = current_sheet(), rows, heights)sheetsheet
rowsrows
heightsheights
The wbWorkbook object, invisibly
remove_row_heights()Sets a row height for a sheet
wbWorkbook$remove_row_heights(sheet = current_sheet(), rows)sheetsheet
rowsrows
The wbWorkbook object, invisibly
description
creates column object for worksheet
createCols()wbWorkbook$createCols(sheet = current_sheet(), n, beg, end)sheetsheet
nn
begbeg
endend
group_cols()Group cols
wbWorkbook$group_cols(
sheet = current_sheet(),
cols,
collapsed = FALSE,
levels = NULL
)sheetsheet
colscols
collapsedcollapsed
levelslevels
The wbWorkbook object, invisibly
ungroup_cols()ungroup cols
wbWorkbook$ungroup_cols(sheet = current_sheet(), cols)sheetsheet
cols= cols
remove_col_widths()Remove row heights from a worksheet
wbWorkbook$remove_col_widths(sheet = current_sheet(), cols)sheetA name or index of a worksheet
colsIndices of columns to remove custom width (if any) from.
The wbWorkbook object, invisibly
set_col_widths()Group cols
wbWorkbook$set_col_widths(
sheet = current_sheet(),
cols,
widths = 8.43,
hidden = FALSE
)sheetsheet
colscols
widthsWidth of columns
hiddenA logical vector to determine which cols are hidden; values
are repeated across length of cols
The wbWorkbook object, invisibly
group_rows()Group rows
wbWorkbook$group_rows(
sheet = current_sheet(),
rows,
collapsed = FALSE,
levels = NULL
)sheetsheet
rowsrows
collapsedcollapsed
levelslevels
The wbWorkbook object, invisibly
ungroup_rows()ungroup rows
wbWorkbook$ungroup_rows(sheet = current_sheet(), rows)sheetsheet
rowsrows
The wbWorkbook object
remove_worksheet()Remove a worksheet
wbWorkbook$remove_worksheet(sheet = current_sheet())sheetThe worksheet to delete
The wbWorkbook object, invisibly
add_data_validation()Adds data validation
wbWorkbook$add_data_validation(
sheet = current_sheet(),
cols,
rows,
type,
operator,
value,
allowBlank = TRUE,
showInputMsg = TRUE,
showErrorMsg = TRUE,
errorStyle = NULL,
errorTitle = NULL,
error = NULL,
promptTitle = NULL,
prompt = NULL
)sheetsheet
colscols
rowsrows
typetype
operatoroperator
valuevalue
allowBlankallowBlank
showInputMsgshowInputMsg
showErrorMsgshowErrorMsg
errorStyleThe icon shown and the options how to deal with such inputs. Default "stop" (cancel), else "information" (prompt popup) or "warning" (prompt accept or change input)
errorTitleThe error title
errorThe error text
promptTitleThe prompt title
promptThe prompt text
merge_cells()Set cell merging for a sheet
wbWorkbook$merge_cells(sheet = current_sheet(), rows = NULL, cols = NULL)sheetsheet
rows, colsRow and column specifications.
The wbWorkbook object, invisibly
unmerge_cells()Removes cell merging for a sheet
wbWorkbook$unmerge_cells(sheet = current_sheet(), rows = NULL, cols = NULL)sheetsheet
rows, colsRow and column specifications.
The wbWorkbook object, invisibly
freeze_pane()Set freeze panes for a sheet
wbWorkbook$freeze_pane(
sheet = current_sheet(),
firstActiveRow = NULL,
firstActiveCol = NULL,
firstRow = FALSE,
firstCol = FALSE
)sheetsheet
firstActiveRowfirstActiveRow
firstActiveColfirstActiveCol
firstRowfirstRow
firstColfirstCol
The wbWorkbook object, invisibly
add_comment()Add comment
wbWorkbook$add_comment(
sheet = current_sheet(),
col,
row,
dims = rowcol_to_dims(row, col),
comment
)sheetsheet
colcolumn to apply the comment
rowrow to apply the comment
dimsrow and column as spreadsheet dimension, e.g. "A1"
commenta comment to apply to the worksheet
remove_comment()Remove comment
wbWorkbook$remove_comment(
sheet = current_sheet(),
col,
row,
dims = rowcol_to_dims(row, col),
gridExpand = TRUE
)sheetsheet
colcolumn to apply the comment
rowrow to apply the comment
dimsrow and column as spreadsheet dimension, e.g. "A1"
gridExpandRemove all comments inside the grid. Similar to dims "A1:B2"
add_conditional_formatting()Add conditional formatting
wbWorkbook$add_conditional_formatting(
sheet = current_sheet(),
cols,
rows,
rule = NULL,
style = NULL,
type = c("expression", "colorScale", "dataBar", "duplicatedValues", "containsText",
"notContainsText", "beginsWith", "endsWith", "between", "topN", "bottomN"),
params = list(showValue = TRUE, gradient = TRUE, border = TRUE, percent = FALSE, rank =
5L)
)sheetsheet
colscols
rowsrows
rulerule
stylestyle
typetype
paramsAdditional parameters
add_image()Insert an image into a sheet
wbWorkbook$add_image(
sheet = current_sheet(),
file,
width = 6,
height = 3,
startRow = 1,
startCol = 1,
rowOffset = 0,
colOffset = 0,
units = "in",
dpi = 300
)sheetsheet
filefile
widthwidth
heightheight
startRowstartRow
startColstartCol
rowOffsetrowOffset
colOffsetcolOffset
unitsunits
dpidpi
The wbWorkbook object, invisibly
add_plot()Add plot. A wrapper for add_image()
wbWorkbook$add_plot(
sheet = current_sheet(),
width = 6,
height = 4,
xy = NULL,
startRow = 1,
startCol = 1,
rowOffset = 0,
colOffset = 0,
fileType = "png",
units = "in",
dpi = 300
)sheetsheet
widthwidth
heightheight
xyxy
startRowstartRow
startColstartCol
rowOffsetrowOffset
colOffsetcolOffset
fileTypefileType
unitsunits
dpidpi
The wbWorkbook object, invisibly; called for its side-effects
protect()Protect a workbook
wbWorkbook$protect(
protect = TRUE,
password = NULL,
lockStructure = FALSE,
lockWindows = FALSE,
type = c("1", "2", "4", "8"),
fileSharing = FALSE,
username = unname(Sys.info()["user"]),
readOnlyRecommended = FALSE
)protectprotect
passwordpassword
lockStructurelockStructure
lockWindowslockWindows
typetype
fileSharingfileSharing
usernameusername
readOnlyRecommendedreadOnlyRecommended
The wbWorkbook object, invisibly
protect_worksheet()protect worksheet
wbWorkbook$protect_worksheet(
sheet = current_sheet(),
protect = TRUE,
password = NULL,
properties = NULL
)sheetsheet
protectprotect
passwordpassword
propertiesA character vector of properties to lock. Can be one
or more of the following: "selectLockedCells",
"selectUnlockedCells", "formatCells", "formatColumns",
"formatRows", "insertColumns", "insertRows",
"insertHyperlinks", "deleteColumns", "deleteRows", "sort",
"autoFilter", "pivotTables", "objects", "scenarios"
set_creators()Set creator(s)
wbWorkbook$set_creators(creators)creatorsA character vector of creators to set. Duplicates are ignored.
add_creators()Add creator(s)
wbWorkbook$add_creators(creators)creatorsA character vector of creators to add. Duplicates are ignored.
remove_creators()Remove creator(s)
wbWorkbook$remove_creators(creators)creatorsA character vector of creators to remove. All duplicated are removed.
set_last_modified_by()Change the last modified by
wbWorkbook$set_last_modified_by(LastModifiedBy = NULL)LastModifiedByA new value
The wbWorkbook object, invisibly
page_setup()page_setup()
wbWorkbook$page_setup(
sheet = current_sheet(),
orientation = NULL,
scale = 100,
left = 0.7,
right = 0.7,
top = 0.75,
bottom = 0.75,
header = 0.3,
footer = 0.3,
fitToWidth = FALSE,
fitToHeight = FALSE,
paperSize = NULL,
printTitleRows = NULL,
printTitleCols = NULL,
summaryRow = NULL,
summaryCol = NULL
)sheetsheet
orientationorientation
scalescale
leftleft
rightright
toptop
bottombottom
headerheader
footerfooter
fitToWidthfitToWidth
fitToHeightfitToHeight
paperSizepaperSize
printTitleRowsprintTitleRows
printTitleColsprintTitleCols
summaryRowsummaryRow
summaryColsummaryCol
The wbWorkbook object, invisibly
set_header_footer()Sets headers and footers
wbWorkbook$set_header_footer(
sheet = current_sheet(),
header = NULL,
footer = NULL,
evenHeader = NULL,
evenFooter = NULL,
firstHeader = NULL,
firstFooter = NULL
)sheetsheet
headerheader
footerfooter
evenHeaderevenHeader
evenFooterevenFooter
firstHeaderfirstHeader
firstFooterfirstFooter
The wbWorkbook object, invisibly
get_tables()get tables
wbWorkbook$get_tables(sheet = current_sheet())sheetsheet
remove_tables()remove tables
wbWorkbook$remove_tables(sheet = current_sheet(), table)sheetsheet
tabletable
add_filter()add filters
wbWorkbook$add_filter(sheet = current_sheet(), rows, cols)sheetsheet
rowsrows
colscols
remove_filter()remove filters
wbWorkbook$remove_filter(sheet = current_sheet())sheetsheet
grid_lines()grid lines
wbWorkbook$grid_lines(sheet = current_sheet(), show = FALSE)sheetsheet
showshow
add_named_region()add a named region
wbWorkbook$add_named_region(
sheet = current_sheet(),
cols,
rows,
name,
localSheetId = NULL,
overwrite = FALSE
)sheetsheet
colscols
rowsrows
namename
localSheetIdlocalSheetId
overwriteoverwrite
remove_named_region()remove a named region
wbWorkbook$remove_named_region(sheet = current_sheet(), name = NULL)sheetsheet
namename
set_order()set worksheet order
wbWorkbook$set_order(sheets)sheetssheets
The wbWorkbook object
get_sheet_visibility()Get sheet visibility
wbWorkbook$get_sheet_visibility()
set_sheet_visibility()Set sheet visibility
wbWorkbook$set_sheet_visibility(sheet = current_sheet(), value)sheetsheet
valuevalue
add_page_break()Add a page break
wbWorkbook$add_page_break(sheet = current_sheet(), row = NULL, col = NULL)sheetsheet
rowrow
colcol
clean_sheet()clean sheet (remove all values)
wbWorkbook$clean_sheet(
sheet = current_sheet(),
numbers = TRUE,
characters = TRUE,
styles = TRUE,
merged_cells = TRUE
)sheetsheet
numbersremove all numbers
charactersremove all characters
stylesremove all styles
merged_cellsremove all merged_cells
The wbWorksheetObject, invisibly
add_border()create borders for cell region
wbWorkbook$add_border(
sheet = current_sheet(),
dims = "A1",
bottom_color = wb_colour(hex = "FF000000"),
left_color = wb_colour(hex = "FF000000"),
right_color = wb_colour(hex = "FF000000"),
top_color = wb_colour(hex = "FF000000"),
bottom_border = "thin",
left_border = "thin",
right_border = "thin",
top_border = "thin",
inner_hgrid = NULL,
inner_hcolor = NULL,
inner_vgrid = NULL,
inner_vcolor = NULL
)sheeta worksheet
dimsdimensions on the worksheet e.g. "A1", "A1:A5", "A1:H5"
bottom_color, left_color, right_color, top_color, inner_hcolor, inner_vcolora color, either something openxml knows or some RGB color
left_border, right_border, top_border, bottom_border, inner_hgrid, inner_vgridthe border style, if NULL no border is drawn. See create_border for possible border styles
The wbWorksheetObject, invisibly
wb <- wb_workbook()
wb$add_worksheet("S1")$add_data("S1", mtcars)
wb$add_border(1, dims = "A1:K1",
left_border = NULL, right_border = NULL,
top_border = NULL, bottom_border = "double")
wb$add_border(1, dims = "A5",
left_border = "dotted", right_border = "dotted",
top_border = "hair", bottom_border = "thick")
wb$add_border(1, dims = "C2:C5")
wb$add_border(1, dims = "G2:H3")
wb$add_border(1, dims = "G12:H13",
left_color = wb_colour(hex = "FF9400D3"), right_color = wb_colour(hex = "FF4B0082"),
top_color = wb_colour(hex = "FF0000FF"), bottom_color = wb_colour(hex = "FF00FF00"))
wb$add_border(1, dims = "A20:C23")
wb$add_border(1, dims = "B12:D14",
left_color = wb_colour(hex = "FFFFFF00"), right_color = wb_colour(hex = "FFFF7F00"),
bottom_color = wb_colour(hex = "FFFF0000"))
wb$add_border(1, dims = "D28:E28")
# if (interactive()) wb$open()wb <- wb_workbook()
wb$add_worksheet("S1")$add_data("S1", mtcars)
wb$add_border(1, dims = "A2:K33", inner_vgrid = "thin", inner_vcolor = c(rgb="FF808080"))
add_fill()provide simple fill function
wbWorkbook$add_fill(
sheet = current_sheet(),
dims = "A1",
color = wb_colour(hex = "FFFFFF00"),
pattern = "solid",
gradient_fill = "",
every_nth_col = 1,
every_nth_row = 1
)sheetthe worksheet
dimsthe cell range
colorthe colors to apply, e.g. yellow: wb_colour(hex = "FFFFFF00")
patternvarious default "none" but others are possible: "solid", "mediumGray", "darkGray", "lightGray", "darkHorizontal", "darkVertical", "darkDown", "darkUp", "darkGrid", "darkTrellis", "lightHorizontal", "lightVertical", "lightDown", "lightUp", "lightGrid", "lightTrellis", "gray125", "gray0625"
gradient_filla gradient fill xml pattern.
every_nth_colwhich col should be filled
every_nth_rowwhich row should be filled
The wbWorksheetObject, invisibly
# example from the gradient fill manual page
gradient_fill <- "<gradientFill degree=\"90\">
<stop position=\"0\"><color rgb=\"FF92D050\"/></stop>
<stop position=\"1\"><color rgb=\"FF0070C0\"/></stop>
</gradientFill>"
add_font()provide simple font function
wbWorkbook$add_font(
sheet = current_sheet(),
dims = "A1",
name = "Calibri",
color = wb_colour(hex = "FF000000"),
size = "11",
bold = "",
italic = "",
outline = "",
strike = "",
underline = "",
charset = "",
condense = "",
extend = "",
family = "",
scheme = "",
shadow = "",
vertAlign = ""
)sheetthe worksheet
dimsthe cell range
namefont name: default "Calibri"
colorrgb color: default "FF000000"
sizefont size: default "11",
boldbold
italicitalic
outlineoutline
strikestrike
underlineunderline
charsetcharset
condensecondense
extendextend
familyfont family
schemefont scheme
shadowshadow
vertAlignvertical alignment
The wbWorksheetObject, invisibly
wb <- wb_workbook()$add_worksheet("S1")$add_data("S1", mtcars)
wb$add_font("S1", "A1:K1", name = "Arial", color = wb_colour(theme = "4"))
add_numfmt()provide simple number format function
wbWorkbook$add_numfmt(sheet = current_sheet(), dims = "A1", numfmt)sheetthe worksheet
diA Workbook
minor helper wrapping xl_open which does the entire same thing
create_border
## ------------------------------------------------
## Method `wbWorkbook$add_border`
## ------------------------------------------------
wb <- wb_workbook()
wb$add_worksheet("S1")$add_data("S1", mtcars)
wb$add_border(1, dims = "A1:K1",
left_border = NULL, right_border = NULL,
top_border = NULL, bottom_border = "double")
wb$add_border(1, dims = "A5",
left_border = "dotted", right_border = "dotted",
top_border = "hair", bottom_border = "thick")
wb$add_border(1, dims = "C2:C5")
wb$add_border(1, dims = "G2:H3")
wb$add_border(1, dims = "G12:H13",
left_color = wb_colour(hex = "FF9400D3"), right_color = wb_colour(hex = "FF4B0082"),
top_color = wb_colour(hex = "FF0000FF"), bottom_color = wb_colour(hex = "FF00FF00"))
wb$add_border(1, dims = "A20:C23")
wb$add_border(1, dims = "B12:D14",
left_color = wb_colour(hex = "FFFFFF00"), right_color = wb_colour(hex = "FFFF7F00"),
bottom_color = wb_colour(hex = "FFFF0000"))
wb$add_border(1, dims = "D28:E28")
# if (interactive()) wb$open()
wb <- wb_workbook()
wb$add_worksheet("S1")$add_data("S1", mtcars)
wb$add_border(1, dims = "A2:K33", inner_vgrid = "thin", inner_vcolor = c(rgb="FF808080"))
## ------------------------------------------------
## Method `wbWorkbook$add_fill`
## ------------------------------------------------
# example from the gradient fill manual page
gradient_fill <- "
"
## ------------------------------------------------
## Method `wbWorkbook$add_font`
## ------------------------------------------------
wb <- wb_workbook()$add_worksheet("S1")$add_data("S1", mtcars)
wb$add_font("S1", "A1:K1", name = "Arial", color = wb_colour(theme = "4"))
## ------------------------------------------------
## Method `wbWorkbook$add_numfmt`
## ------------------------------------------------
wb <- wb_workbook()$add_worksheet("S1")$add_data("S1", mtcars)
wb$add_numfmt("S1", "A1:A33", numfmt = 1)
## ------------------------------------------------
## Method `wbWorkbook$add_cell_style`
## ------------------------------------------------
wb <- wb_workbook()$add_worksheet("S1")$add_data("S1", mtcars)
wb$add_cell_style("S1", "A1:K1",
textRotation = "45",
horizontal = "center",
vertical = "center",
wrapText = "1")
Run the code above in your browser using DataLab