如何使用 Shiny 中的 DataTable Extensions 更改下载文件中的名称?
How can I change the name inside the downloaded file with DataTable Extensions in Shiny?
我创建了一个闪亮的应用程序,我可以在其中下载各种文件格式(pdf、excel、csv)的 table。但是,我发现它们每个都具有与我的 Shiny App 相同的标题(“这是我的 table in Shiny”)。
我使用 DataTable 中的这个 extension。
有谁知道我是否可以从下载的文件中删除该标题?
这是我的应用程序的外观。
这些是下载的文件(excel 和 pdf)
我的代码:
library(shiny)
library(DT)
ui <- fluidPage(
# Application title
titlePanel("This is my table in Shiny")
, mainPanel(
DT::dataTableOutput("fancyTable")
)
)
server <- function(input, output) {
output$fancyTable <- DT::renderDataTable(
datatable( data = mtcars
, extensions = 'Buttons'
, options = list(
dom = "Blfrtip"
, buttons =
list("copy", list(
extend = "collection"
, buttons = c("csv", "excel", "pdf")
, text = "Download"
) )
, lengthMenu = list( c(10, 20, -1)
, c(10, 20, "All")
)
, pageLength = 10
)
)
)
}
# Run the application
shinyApp(ui = ui, server = server)
提前致谢
此致
尝试了很多东西并搜索了其他帖子...我找到了解决方案!
我需要将每个选项放入一个列表中,以便能够为每个选项添加“标题”参数。
library(shiny)
library(DT)
ui <- fluidPage(
# Application title
titlePanel("This is my table in Shiny")
, mainPanel(
DT::dataTableOutput("fancyTable")
)
)
server <- function(input, output) {
output$fancyTable <- DT::renderDataTable(
datatable( data = mtcars
, extensions = 'Buttons'
, options = list(
dom = "Blfrtip",
buttons =
list("copy", list(
extend = "collection",
buttons = list(
list(extend = "csv", title = "MY TITLE"),
list(extend = "excel", title = "MY TITLE"),
list(extend = "pdf", title = "MY TITLE")),
text = "Download"
)),
lengthMenu = list( c(10, 20, -1)
, c(10, 20, "All")
),
pageLength = 10
)
)
)
}
# Run the application
shinyApp(ui = ui, server = server)
在这里你可以看到新标题!
我创建了一个闪亮的应用程序,我可以在其中下载各种文件格式(pdf、excel、csv)的 table。但是,我发现它们每个都具有与我的 Shiny App 相同的标题(“这是我的 table in Shiny”)。
我使用 DataTable 中的这个 extension。
有谁知道我是否可以从下载的文件中删除该标题?
这是我的应用程序的外观。
这些是下载的文件(excel 和 pdf)
我的代码:
library(shiny)
library(DT)
ui <- fluidPage(
# Application title
titlePanel("This is my table in Shiny")
, mainPanel(
DT::dataTableOutput("fancyTable")
)
)
server <- function(input, output) {
output$fancyTable <- DT::renderDataTable(
datatable( data = mtcars
, extensions = 'Buttons'
, options = list(
dom = "Blfrtip"
, buttons =
list("copy", list(
extend = "collection"
, buttons = c("csv", "excel", "pdf")
, text = "Download"
) )
, lengthMenu = list( c(10, 20, -1)
, c(10, 20, "All")
)
, pageLength = 10
)
)
)
}
# Run the application
shinyApp(ui = ui, server = server)
提前致谢
此致
尝试了很多东西并搜索了其他帖子...我找到了解决方案!
我需要将每个选项放入一个列表中,以便能够为每个选项添加“标题”参数。
library(shiny)
library(DT)
ui <- fluidPage(
# Application title
titlePanel("This is my table in Shiny")
, mainPanel(
DT::dataTableOutput("fancyTable")
)
)
server <- function(input, output) {
output$fancyTable <- DT::renderDataTable(
datatable( data = mtcars
, extensions = 'Buttons'
, options = list(
dom = "Blfrtip",
buttons =
list("copy", list(
extend = "collection",
buttons = list(
list(extend = "csv", title = "MY TITLE"),
list(extend = "excel", title = "MY TITLE"),
list(extend = "pdf", title = "MY TITLE")),
text = "Download"
)),
lengthMenu = list( c(10, 20, -1)
, c(10, 20, "All")
),
pageLength = 10
)
)
)
}
# Run the application
shinyApp(ui = ui, server = server)
在这里你可以看到新标题!