protectWorkbook

0th

Percentile

Protect a workbook from modifications

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

Usage
protectWorkbook(
  wb,
  protect = TRUE,
  password = NULL,
  lockStructure = FALSE,
  lockWindows = FALSE
)
Arguments
wb

A workbook object

protect

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

password

(optional) password required to unprotect the workbook

lockStructure

Whether the workbook structure should be locked

lockWindows

Whether the window position of the spreadsheet should be locked

Aliases
  • protectWorkbook
Examples
# NOT RUN {
wb <- createWorkbook()
addWorksheet(wb, "S1")
protectWorkbook(wb, protect = TRUE, password = "Password", lockStructure = TRUE)
# }
# NOT RUN {
saveWorkbook(wb, "WorkBook_Protection.xlsx", overwrite = TRUE)
# }
# NOT RUN {
# Remove the protection
protectWorkbook(wb, protect = FALSE)
# }
# NOT RUN {
saveWorkbook(wb, "WorkBook_Protection_unprotected.xlsx", overwrite = TRUE)
# }
Documentation reproduced from package openxlsx, version 4.1.5, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.