【问题标题】:Exporting TextAreaInput as .txt file将 TextAreaInput 导出为 .txt 文件
【发布时间】:2018-11-28 14:48:46
【问题描述】:

您能否与我分享一个闪亮的应用程序示例,其中使用下载按钮将 textAreaInput 的内容导出为 .txt 文件。 谢谢。

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    你可以这样做:

    library(shiny)
    
    ui <- fluidPage(
      textAreaInput("text", "Enter text:"),
      downloadButton("download", "Download")
    )
    
    server <- function(input, output) {
    
      output$download <- downloadHandler(
        filename = function() {
          "textarea.txt"
        },
        content = function(file) {
          cat(input$text, file=file)
        }
      )
    }
    
    shinyApp(ui, server)
    

    【讨论】:

    • 感谢 Stéphane,这正是我想要的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-23
    • 2022-01-20
    • 1970-01-01
    • 1970-01-01
    • 2022-01-20
    • 1970-01-01
    相关资源
    最近更新 更多