Hi andresrcs,
Thank your for your support. Actually when i copy and run there is an error
Error: :15:185: unexpected symbol
14: #Set the name of the file
15: name<-pastepaste0(str_to_sentence(month(floor_date(Sys.Date(), unit = "month") - 1, label = TRUE)), "_", year(Sys.Date()), "paste0(str_to_sentence(month(floor_date(Sys.Date(), unit = "month
This is the full code of mine
#Input required libraries
library(XLConnect)
library(XLConnectJars)
library(lubridate)
library(stringr)
#Read the data from the flow
knime.out <- knime.in
#Open the library for formating
*options(java.parameters = "-Xmx28672m") *
require(XLConnect)
#Set the name of the file
name<-pastepaste0(str_to_sentence(month(floor_date(Sys.Date(), unit = "month") - 1, label = TRUE)), "", year(Sys.Date()), "paste0(str_to_sentence(month(floor_date(Sys.Date(), unit = "month") - 1, label = TRUE)), "", year(Sys.Date()), "_List.xlsx" )
#Prepare the template. Save it in the wanted location and close. Set the path to the template below:
template<-"C:\Users\uic61877\Desktop\EXECUTIVE LIST\Executives_Gradings_Database\KNIME workflow\intermediate_steps\Step 3\Step3_database.xlsx"
#Set the path to save the local copy of the file (on the computer)
new.folder<-"C:\Users\uic61877\Desktop\EXECUTIVE LIST\Executives_Gradings_Database\monthly lists"
#Copy the template to the new location
file.copy(template, new.folder)
#Set the working directory to the location
setwd(new.folder)
#Rename the template with the name of the current file. Check if the name of the template in "" is correct
file.rename("Step3_database.xlsx",name)
#Open the xls
wb <- loadWorkbook(name, create=FALSE)
setStyleAction(wb,XLC$"STYLE_ACTION.NONE")
#Write data from the flow
writeWorksheet(wb,knime.out, sheet = "Executives who left", startRow=4,startCol=1,header=FALSE)
#Save the data
saveWorkbook(wb)
There is one more thing i forget to mention in the question that in case the current month is Jan_2020 than the file should be named as Dec_20219_List but when i read your code it does the minus for month only.