setAutoFilter-methods: Setting auto-filters on worksheets

Description Usage Arguments Author(s) See Also Examples

Description

Sets an auto-filter on a specified worksheet.

Usage

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

Arguments

object

The workbook to use

sheet

The name or index of the sheet on which to set the auto-filter

reference

A cell range specification (character) in the form 'A1:B8'

Author(s)

Martin Studer
Mirai Solutions GmbH https://mirai-solutions.ch

See Also

workbook

Examples

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

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

# Create a named region called 'mtcars' on the sheet called 'mtcars'
createName(wb, name = "mtcars", formula = "mtcars!$A$1")

# Write built-in data set 'mtcars' to the above defined named region
# (using header = TRUE)
writeNamedRegion(wb, mtcars, name = "mtcars")

# Set an auto-filter for the named region written above
setAutoFilter(wb, sheet = "mtcars", reference = aref("A1", dim(mtcars)))

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

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

## End(Not run)

XLConnect documentation built on Oct. 1, 2021, 5:06 p.m.