[英]How can I change the name inside the downloaded file with DataTable Extensions in Shiny?
我創建了一個 Shiny 應用程序,我可以在其中下載各種文件格式的表格(pdf、excel、csv)。 但是,我發現它們每個都具有與我的 Shiny 應用程序相同的標題(“這是我在 Shiny 中的表”)。
我使用 DataTable 中的這個擴展。
有誰知道我是否可以從下載的文件中刪除該標題?
我的代碼:
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)
在這里你可以看到新的標題!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.