I have written the following server code to display the content. How to download the file after I edit the hands-on table
#server
value <- eventReactive(input$file, {
theFile <- input$file
if(is.null(theFile)) {
return(NULL)}
file.rename(theFile$datapath,paste(theFile$datapath, ".xlsx", sep=""))
Data <- read_excel(paste(theFile$datapath, ".xlsx", sep = ""), 1)
Data
})
output$contents <- renderRHandsontable({
rhandsontable(value())
})
I would add an actionButton in ui.R and use it to save the file.
actionButton in ui.R:
actionButton("savefile", "Save", width = '100%')
To save the file, in server.R:
observeEvent(input$savefile,
{
if (!is.null(isolate(input$contents)))
{
#Convert to R object
x <- hot_to_r(isolate(input$contents))
write.table(x, file = 'employee_input.txt', row.names=FALSE, quote = TRUE, sep = ",",
na = "NA", dec = ".")
}
}
)