I´m currently looking for a way to duplicate excel files with R (I guess it might work with xlsx but I didnt figure out how to yet). Copying the values out of the cells into a new file or loading the information into R wont work for my usecase. I didnt find anything usefull so far and it´s the first time that I code in R so I hope somebody can help!
EDIT: I added the code that I used for the advice with file.copy which doesnt seem to work for me so far
path_cwd <- getwd()
path_cwd
#gibt Ordner mit Excel Datei an
path_other <- "C:\\UserData\\z003xbys\\Documents\\Excel-R"
#gibt files im aktuellen working directory zurück
destination <- dir(path_other, "*.xlsx", ignore.case = TRUE)
file.copy(destination, path_cwd, overwrite = TRUE, copy.mode = TRUE, copy.date
= TRUE)
Greetings Luis
You can copy an Excel file with the following approach :
library(RDCOMClient)
path_Excel_File_Input <- "D:\\file1.xlsx"
path_Excel_File_Output <- "D:\\file2.xlsx"
xlApp <- COMCreate("Excel.Application")
xlWbk <- xlApp$Workbooks()$Open(path_Excel_File_Input)
xlWbk$SaveAs(path_Excel_File_Output)