How do I password-protect an Excel file created in R with write.xlsx?

放肆的年华 提交于 2019-12-07 13:18:46

问题


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:


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)


来源:https://stackoverflow.com/questions/50867641/how-do-i-password-protect-an-excel-file-created-in-r-with-write-xlsx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!