protectWorksheet: Protect a worksheet from modifications

Description Usage Arguments Author(s) Examples

Description

Protect or unprotect a worksheet from modifications by the user in the graphical user interface. Replaces an existing protection.

Usage

1
2
3
4
5
6
7
8
protectWorksheet(wb, sheet, protect = TRUE, password = NULL,
  lockSelectingLockedCells = NULL, lockSelectingUnlockedCells = NULL,
  lockFormattingCells = NULL, lockFormattingColumns = NULL,
  lockFormattingRows = NULL, lockInsertingColumns = NULL,
  lockInsertingRows = NULL, lockInsertingHyperlinks = NULL,
  lockDeletingColumns = NULL, lockDeletingRows = NULL,
  lockSorting = NULL, lockAutoFilter = NULL, lockPivotTables = NULL,
  lockObjects = NULL, lockScenarios = NULL)

Arguments

wb

A workbook object

sheet

A name or index of a worksheet

protect

Whether to protect or unprotect the sheet (default=TRUE)

password

(optional) password required to unprotect the worksheet

lockSelectingLockedCells

Whether selecting locked cells is locked

lockSelectingUnlockedCells

Whether selecting unlocked cells is locked

lockFormattingCells

Whether formatting cells is locked

lockFormattingColumns

Whether formatting columns is locked

lockFormattingRows

Whether formatting rows is locked

lockInsertingColumns

Whether inserting columns is locked

lockInsertingRows

Whether inserting rows is locked

lockInsertingHyperlinks

Whether inserting hyperlinks is locked

lockDeletingColumns

Whether deleting columns is locked

lockDeletingRows

Whether deleting rows is locked

lockSorting

Whether sorting is locked

lockAutoFilter

Whether auto-filter is locked

lockPivotTables

Whether pivot tables are locked

lockObjects

Whether objects are locked

lockScenarios

Whether scenarios are locked

Author(s)

Reinhold Kainhofer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
wb <- createWorkbook()
addWorksheet(wb, "S1")
writeDataTable(wb, 1, x = iris[1:30,])
# Formatting cells / columns is allowed , but inserting / deleting columns is protected:
protectWorksheet(wb, "S1", protect = TRUE, lockFormattingCells = FALSE, lockFormattingColumns = FALSE, lockInsertingColumns = TRUE, lockDeletingColumns = TRUE)

# Remove the protection
protectWorksheet(wb, "S1", protect = FALSE)

saveWorkbook(wb, "pageSetupExample.xlsx", overwrite = TRUE)

awalker89/openxlsx documentation built on May 11, 2019, 4:09 p.m.