问题
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