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)
}
Run the code above in your browser using DataLab