writing R to xlsx2 naming sheetname today's date after doing taskscheduler

221 Views Asked by At

I'm trying to run an automated script using Rstudio add-in TaskscheduleR everyday. Then saving that to an appended excel spreadsheet with today's date.

But I get the below error each time. I can get the writexlsx2 to work if I name the sheetname="abc", but not if I try to name it today's date. That way the I know what date the scheduler excel output ran. Any ideas how to label the Excel tab today's date when TaskscheduleR runs?

 currentDate <- Sys.Date()
write.xlsx2(mydata, "mydata with Clicklist.xlsx", sheetName=currentDate, col.names = TRUE, row.names =TRUE, append=TRUE)

Error in .jcall(wb, "Lorg/apache/poi/ss/usermodel/Sheet;", "createSheet",  : 

method createSheet with signature (D)Lorg/apache/poi/ss/usermodel/Sheet; not found

1

There are 1 best solutions below

0
On

I'm guessing you just need to convert currentDate into a string. as.character(currentDate) will probably do it.