I've run all the online examples. I asked a friend to try on their machine. I tried on my office machine.
Am I doing something wrong? None of the sheets has any prompt for password, or read-only ....
library(openxlsx)
df = data.frame(Year = c(2018,2019,2020,2018,2019,2020,2018,2019,2020),
Country = c("Germany","Germany","Germany", "Japan", "Japan", "Japan", "Thailand", "Thailand", "Thailand"),
Count = c(17, 15, 60, 23, 25, 60, 50, 18, 31))
wb = createWorkbook()
addWorksheet(wb, "Master")
writeDataTable(wb, "Master", df, tableStyle = "TableStyleLight9")
protectWorkbook(wb, type=2)
saveWorkbook(wb, "ReadOnly.xlsx", overwrite = TRUE)
wb <- createWorkbook()
addWorksheet(wb, "S1")
protectWorkbook(wb, protect = TRUE, password = "6%220b*235apple", lockStructure = TRUE)
saveWorkbook(wb, "WorkBook_Protection.xlsx", overwrite = TRUE)
#openXL(wb)
df = data.frame(Year = c(2018,2019,2020,2018,2019,2020,2018,2019,2020),
Country = c("Germany","Germany","Germany", "Japan", "Japan", "Japan", "Thailand", "Thailand", "Thailand"),
Count = c(17, 15, 60, 23, 25, 60, 50, 18, 31))
wb = createWorkbook()
addWorksheet(wb, "Master")
writeDataTable(wb, "Master", df, tableStyle = "TableStyleLight9")
yellow_style = createStyle(fgFill = "#FFFF00")
y = which(colnames(df) == "Count")
x = which(abs(df$Count) > 32)
addStyle(wb, sheet = "Master", style = yellow_style, rows = x+1, col = y)
protectWorkbook(wb, protect = TRUE, password = "6%220b*235apple", lockStructure = TRUE)
saveWorkbook(wb, "Master.xlsx", overwrite = TRUE)
#openXL(wb)
wb <- createWorkbook()
addWorksheet(wb, "main")
writeDataTable(wb, "main", head(iris), tableStyle = "TableStyleLight9")
disables the ability to add or remove sheets from the workbook
protectWorkbook(wb, protect = TRUE, password = "6%220b*235apple", lockStructure = TRUE)
locks the sheet against any modification, see link above for fine tuning
protectWorksheet(wb, "main", protect = TRUE, password = "6%220b*235apple")
tmp <- temp_xlsx()
saveWorkbook(wb, tmp, overwrite = TRUE)
#openXL(tmp)
#openXL(wb)
I've run all the online examples. I asked a friend to try on their machine. I tried on my office machine.
Am I doing something wrong? None of the sheets has any prompt for password, or read-only ....
library(openxlsx)
df = data.frame(Year = c(2018,2019,2020,2018,2019,2020,2018,2019,2020),
Country = c("Germany","Germany","Germany", "Japan", "Japan", "Japan", "Thailand", "Thailand", "Thailand"),
Count = c(17, 15, 60, 23, 25, 60, 50, 18, 31))
wb = createWorkbook()
addWorksheet(wb, "Master")
writeDataTable(wb, "Master", df, tableStyle = "TableStyleLight9")
protectWorkbook(wb, type=2)
saveWorkbook(wb, "ReadOnly.xlsx", overwrite = TRUE)
wb <- createWorkbook()
addWorksheet(wb, "S1")
protectWorkbook(wb, protect = TRUE, password = "6%220b*235apple", lockStructure = TRUE)
saveWorkbook(wb, "WorkBook_Protection.xlsx", overwrite = TRUE)
#openXL(wb)
df = data.frame(Year = c(2018,2019,2020,2018,2019,2020,2018,2019,2020),
Country = c("Germany","Germany","Germany", "Japan", "Japan", "Japan", "Thailand", "Thailand", "Thailand"),
Count = c(17, 15, 60, 23, 25, 60, 50, 18, 31))
wb = createWorkbook()
addWorksheet(wb, "Master")
writeDataTable(wb, "Master", df, tableStyle = "TableStyleLight9")
yellow_style = createStyle(fgFill = "#FFFF00")
y = which(colnames(df) == "Count")
x = which(abs(df$Count) > 32)
addStyle(wb, sheet = "Master", style = yellow_style, rows = x+1, col = y)
protectWorkbook(wb, protect = TRUE, password = "6%220b*235apple", lockStructure = TRUE)
saveWorkbook(wb, "Master.xlsx", overwrite = TRUE)
#openXL(wb)
wb <- createWorkbook()
addWorksheet(wb, "main")
writeDataTable(wb, "main", head(iris), tableStyle = "TableStyleLight9")
disables the ability to add or remove sheets from the workbook
protectWorkbook(wb, protect = TRUE, password = "6%220b*235apple", lockStructure = TRUE)
locks the sheet against any modification, see link above for fine tuning
protectWorksheet(wb, "main", protect = TRUE, password = "6%220b*235apple")
tmp <- temp_xlsx()
saveWorkbook(wb, tmp, overwrite = TRUE)
#openXL(tmp)
#openXL(wb)