How to read password protected excel file in R ?
In this article, we are going to see how to read password-protected Excel files in R programming language.
File in use: file
Method 1: Using excel.link Package.
Here we will use excel.link package to read the file with a password.
xl.read.file() function is used to read Excel files in R programming.
xl.read.file( “file_name”, password = “pass”)
The same module can be used to first unlock the file and then copy its contents onto another so that it can be accessed again without any password. Here we save the file with a password NULL value and save it to another file.
xl.save.file( file.object, “New_file”, password = NULL , write.res.password = NULL)
Method 2: Using XLConnect package.
Here we will use XLConnect package to read the password-protected file. This package provides comprehensive functionality to read, write and format Excel data.
loadWorkbook() function loads Microsoft Excel workbooks.
loadWorkbook(filename , password )
readWorksheet() function reads data from worksheets.
Syntax: readWorksheet( object, sheet).
- Object: The ‘>workbook to use
- Sheet: The name or index of the worksheet to read from