动态下载按钮
Dynamic Download Button
您好,我的 Shiny APP 中的下载按钮有问题。我在创建相应的 DF 时动态创建了按钮。现在我遇到了下载不起作用的问题。如果我直接创建按钮,则下载有效。
我对重置功能做了同样的事情,这里一切正常。
有人可以告诉我我做错了什么吗?
这是 UI 中的按钮代码:
column(3, offset = 0, uiOutput("download.action", style = "text-align: center;"))
我的服务器代码如下所示:
output$download.action <- renderUI({
div(style = "display:inline-block;width:0%;", actionButton("downloadData", "Download", icon = icon("download"),
style = "
flex-grow: 1;
display: inline-block;
background-color:#999;
text-decoration: none;
font-weight: 300;
border: 1px dash transparent;
letter-spacing: 0.98pt;
border-color:#00245d;"))
})
output$downloadData <- downloadHandler(
filename = function() {
paste("test.xlsx")
},
content = function(file) {
write.xlsx(test3, file, row.names = FALSE)
}
)
})
当我直接创建按钮时一切正常。
Shiny 没有给出任何错误信息。只有按钮不起作用。
您应该将 actionButton
替换为 downloadButton
。
output$download.action <- renderUI({
div(style = "display:inline-block;width:0%;", downloadButton("downloadData", "Download", icon = icon("download"),
style = "
flex-grow: 1;
display: inline-block;
background-color:#999;
text-decoration: none;
font-weight: 300;
border: 1px dash transparent;
letter-spacing: 0.98pt;
border-color:#00245d;"))
})
您好,我的 Shiny APP 中的下载按钮有问题。我在创建相应的 DF 时动态创建了按钮。现在我遇到了下载不起作用的问题。如果我直接创建按钮,则下载有效。 我对重置功能做了同样的事情,这里一切正常。 有人可以告诉我我做错了什么吗?
这是 UI 中的按钮代码:
column(3, offset = 0, uiOutput("download.action", style = "text-align: center;"))
我的服务器代码如下所示:
output$download.action <- renderUI({
div(style = "display:inline-block;width:0%;", actionButton("downloadData", "Download", icon = icon("download"),
style = "
flex-grow: 1;
display: inline-block;
background-color:#999;
text-decoration: none;
font-weight: 300;
border: 1px dash transparent;
letter-spacing: 0.98pt;
border-color:#00245d;"))
})
output$downloadData <- downloadHandler(
filename = function() {
paste("test.xlsx")
},
content = function(file) {
write.xlsx(test3, file, row.names = FALSE)
}
)
})
当我直接创建按钮时一切正常。
Shiny 没有给出任何错误信息。只有按钮不起作用。
您应该将 actionButton
替换为 downloadButton
。
output$download.action <- renderUI({
div(style = "display:inline-block;width:0%;", downloadButton("downloadData", "Download", icon = icon("download"),
style = "
flex-grow: 1;
display: inline-block;
background-color:#999;
text-decoration: none;
font-weight: 300;
border: 1px dash transparent;
letter-spacing: 0.98pt;
border-color:#00245d;"))
})