setSheetColor-methods: Setting colors on worksheet tabs

Description Usage Arguments Author(s) See Also Examples

Description

Sets a color on a specified worksheet tab. This only works for xlsx files.

Usage

1
2
3
4
## S4 method for signature 'workbook,character'
setSheetColor(object,sheet,color)
## S4 method for signature 'workbook,numeric'
setSheetColor(object,sheet,color)

Arguments

object

The workbook to use

sheet

The name or index of the sheet on which to set the tab color

color

The color to use for the sheet tab. The color is normally specified via a corresponding color constant from the XLC object.

Author(s)

Nicola Lambiase
Mirai Solutions GmbH https://mirai-solutions.ch

See Also

workbook, XLC

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Not run: 
# Load workbook (create if not existing)
wb <- loadWorkbook("sheetcolor.xlsx", create = TRUE)

# Create a worksheet named 'Sheet1'
createSheet(wb, name = "Sheet1")

# Set the "Sheet1" tab color as red
setSheetColor(wb, "Sheet1", XLC$COLOR.RED)

# Create a worksheet named 'Sheet2'
createSheet(wb, name = "Sheet2")

# Set the tab color of the second workbook sheet as green
setSheetColor(wb, 2, XLC$COLOR.GREEN)

# Save workbook (this actually writes the file to disk)
saveWorkbook(wb)

# clean up 
file.remove("sheetcolor.xlsx")

## End(Not run)

XLConnect documentation built on April 11, 2021, 9:06 a.m.