【问题标题】:Title export options of DT::datatable using shiny app使用闪亮应用程序的 DT::datatable 的标题导出选项
【发布时间】:2020-01-13 01:20:59
【问题描述】:

鉴于以下闪亮的应用程序:

library(shiny)
library(tidyverse)
library(DT)

ui <- fluidPage(
  br(),
  DTOutput("DT")
)

server <- function(input, output) {

  output$DT <- renderDataTable({
    mtcars %>% 
      datatable(.,extensions = 'Buttons',
                options = list(dom = 'Bfrtip',
                               exportOptions = list(header = ""),
                               buttons = c('copy', 'csv', 'excel', 'pdf')))
  })  
}

shinyApp(ui = ui, server = server)

可以使用数据表左上角的按钮复制剪贴板中的完整表。

但是当将内容粘贴到 excel、记事本或任何有标题的地方时,我想删除它。

我很确定可以使用某项删除或更改标题。类似于exportOptions = list(header = ""),。但不足为奇的是,这不起作用。也许人们可以找到或翻译从here 到 R/Shiny 的解决方案。

【问题讨论】:

    标签: r shiny datatable dt


    【解决方案1】:

    这是按钮的title 选项:

    library(shiny)
    library(DT)
    
    ui <- fluidPage(
      br(),
      DTOutput("DT")
    )
    
    server <- function(input, output) {
    
      output$DT <- renderDT({
        mtcars %>% 
          datatable(., extensions = 'Buttons',
                    options = list(
                      dom = 'Bfrtip',
                      buttons = list(
                        list(
                          extend = "copy", 
                          text = "COPY", 
                          title = NULL
                        )
                      )
                    )
          )
      })  
    }
    
    shinyApp(ui = ui, server = server)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-01
      • 2022-01-08
      • 1970-01-01
      • 2016-02-18
      • 2021-09-02
      • 1970-01-01
      • 2021-09-11
      • 2018-09-07
      相关资源
      最近更新 更多