How do I password-protect an Excel file created in

2019-05-10 04:16发布

In my data analysis in R I sometimes output data to Excel files using write.xlsx. These files need to be password-protected, and currently I am doing this by opening the unprotected file using Excel, and then adding a password using File - Protect Workbook - Encrypt with Password.

Is there a way to do this directly in R so that I don't have to open the Excel file and manually add the password? (I want to password-protect the whole workbook, not just a single sheet.)

1条回答
我只想做你的唯一
2楼-- · 2019-05-10 04:51

From the xlsx manual, you can set the password in the password argument:

write.xlsx(x, file, sheetName="Sheet1", col.names=TRUE, row.names=TRUE, append=FALSE, showNA=TRUE, password=NULL)
查看更多
登录 后发表回答