如何使用write.xlsx对在R中创建的Excel文件进行密码保护? [英] How do I password-protect an Excel file created in R with write.xlsx?
问题描述
在R
中的数据分析中,有时会使用write.xlsx
将数据输出到Excel文件.这些文件需要使用密码保护,目前,我正在使用Excel打开不受保护的文件,然后使用File - Protect Workbook - Encrypt with Password
添加密码.
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
.
是否可以直接在R
中执行此操作,从而不必打开Excel文件并手动添加密码? (我想用密码保护整个工作簿,而不仅仅是一张纸.)
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.)
推荐答案
在xlsx手册中,您可以在password参数中设置密码:
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)
这篇关于如何使用write.xlsx对在R中创建的Excel文件进行密码保护?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!