r - 如何在 r Shiny 中使用rhandsontable下载表格?

标签 r shiny handsontable

我编写了以下服务器代码来显示内容。编辑动 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/

相关文章:

jquery - 可手动更改相对于下一列的下一个单元格的单元格颜色

r - 如何在 r 中以水平堆积条形图的样式创建时间序列图

将 x Axis 替换为工作日标签

r - ggplot2 与色盲 ggthemes 除了黑色

html - 在Shiny中使用renderUI显示矢量

r - Shiny DT : format date column in excel through Buttons extensions

javascript - 如何重命名handsontable.js 中的上下文菜单项?

r2 来自素食包中的 envfit

r - 一个 sliderInput 上的多个范围

jquery - 通过 JSON 从 Handsontable 检索数据到 Struts2 Action 不起作用