【发布时间】:2017-11-22 18:27:18
【问题描述】:
我需要从 2 个 SQL 查询中导出图形和 xls 我的图表通过单击一行与数据表链接 我放置了 2 个下载按钮,但我不知道如何使用按钮触发导出(也许使用另一个反应函数?)
感谢您的帮助
这是我的 UI.R:
mainPanel(
DT::dataTableOutput("table"), #My Table
plotOutput("plot")) # My graph
downloadButton("plot_export", "PDF"),
# Button
downloadButton("downloadData", "XLS")
))
这里是 server.R:
cpk_total <- reactive({
data_testeur <- odbcConnect(input$base, uid="uid")
SQL query to feed my dataTable
Close connexion data_testeur
return result created from the SQL query
})
output$Table <- DT::renderDataTable({
DT::datatable(cpk_total(),...) # Formating table
})
output$plot <- renderPlot({
dta <- cpk_total()
data_testeur <- odbcConnect(input$base, uid="uid")
another SQL query to trace the graph for 1 item selected
#This SQL query use a variable from the created cpk_total table
Close connexion data_testeur
graph <- ....
)
【问题讨论】: