我编写了以下服务器代码来显示内容。编辑动 watch 后如何下载文件
#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())
})
最佳答案
我会在 ui.R 中添加一个 actionButton 并用它来保存文件。
ui.R 中的actionButton:
actionButton("savefile", "Save", width = '100%')
要保存文件,请在 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 = ".")
}
}
)
关于r - 如何在 r Shiny 中使用rhandsontable下载表格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47636536/