Now, the 3 xlsx are stored in a folder in my working directory with their workbook name being the Country they have been filtered by. I would like to Password protect them in such a way that it will be a fixed string, "iLove" + first 2 character of their file name.
Example, the password for Workbook "Japan" will be "iLoveJa" and Germany will be "iLoveGe"
Does protectWorkbook do what you want? You can just add the call before the saveWorkbook() call, in your save_data() function. Use paste0() to create the password as you did with the filename.
Hi @dummy123,
The two packages, xlsx and openxlsx, have similar function names but different arguments, that's why the code is not working. Check the help pages to see the differences. If the sheet formatting is not crucial, then I think using xlsx::write.xlsx() may do the job you want.