hideSheet-methods {XLConnect}R Documentation

Hiding worksheets in a workbook

Description

(Very) hides the specified worksheets in a workbook.

Usage

## S4 method for signature 'workbook,character'
hideSheet(object, sheet, veryHidden)
## S4 method for signature 'workbook,numeric'
hideSheet(object, sheet, veryHidden)

Arguments

object

The workbook to use

sheet

The name or index of the sheet to hide

veryHidden

If veryHidden = TRUE, the specified sheet is "very" hidden (see note), otherwise it is just hidden. Default is FALSE.

Details

The arguments sheet and veryHidden are vectorized such that multiple worksheets can be (very) hidden with one method call. An exception is thrown if the specified sheet does not exist.

Note

Note that hidden worksheets can be unhidden by users directly within Excel via standard functionality. Therefore Excel knows the concept of "very hidden" worksheets. These worksheets cannot be unhidden with standard Excel functionality but need programatic intervention to be made visible.

Also note that in case the specified worksheet to hide is the currently active worksheet, then hideSheet tries to set the active worksheet to the first non-hidden (not hidden and not very hidden) worksheet in the workbook. If there is no such worksheet, hideSheet will throw an exception.

Author(s)

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

See Also

workbook, unhideSheet, isSheetHidden, isSheetVeryHidden, isSheetVisible

Examples

## Not run: 
# Load workbook (create if not existing)
wb <- loadWorkbook("hiddenWorksheet.xlsx", create = TRUE)

# Write a couple of built-in data.frame's into sheets
# with corresponding name
for(obj in c("CO2", "airquality", "swiss")) {
  createSheet(wb, name = obj)
  writeWorksheet(wb, get(obj), sheet = obj)
}

# Hide sheet 'airquality';
# the sheet may be unhidden by a user from within Excel
# since veryHidden defaults to FALSE
hideSheet(wb, sheet = "airquality")

# Save workbook
saveWorkbook(wb)

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

## End(Not run)

[Package XLConnect version 1.0.10 Index]