Protect or unprotect a workbook from modifications by the user in the graphical user interface. Replaces an existing protection.
protectWorkbook( wb, protect = TRUE, password = NULL, lockStructure = FALSE, lockWindows = FALSE )
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 |
Reinhold Kainhofer
wb <- createWorkbook() addWorksheet(wb, "S1") protectWorkbook(wb, protect = TRUE, password = "Password", lockStructure = TRUE) if (FALSE) { saveWorkbook(wb, "WorkBook_Protection.xlsx", overwrite = TRUE) } # Remove the protection protectWorkbook(wb, protect = FALSE) if (FALSE) { saveWorkbook(wb, "WorkBook_Protection_unprotected.xlsx", overwrite = TRUE) }