【问题标题】:putting date range to pdf in shiny app在闪亮的应用程序中将日期范围设置为 pdf
【发布时间】:2018-12-11 13:25:58
【问题描述】:

我有一个如下所示的应用程序:enter image description here

我想在该时间段内将数据表下载为 pdf。但是当我这样做时,只有表导出。 enter image description here

这里是ma ui.R代码:

library(shiny)
  jscode <- "shinyjs.closeWindow = function() { window.close(); }"


 shinyUI(fluidPage(   




  tags$head(
tags$style(HTML("
                @import url('//fonts.googleapis.com/css?family=Anton');

                h2 {
                font-family: 'Anton';
                font-weight: 600;
                line-height: 0.7;
                color: #483D8B;
                }

                "))
),


titlePanel("ZESTAWIENIE 1 v 2"),


sidebarLayout(

  sidebarPanel( tags$head(
    tags$style(type="text/css", ".well { width: 150px; }"),
  tags$style(type="text/css", ".col-sm-4 { width: 170px;}"),
# tags$style(type="text/css", "#close {font-size: 12px; background-color:  #e6e6e6; }") ,
 tags$style(type="text/css", "#get_data { font-size: 12px; background-color:  #e6e6e6;}") ,
  tags$style(type="text/css", "#last_month { font-size: 12px;background-color:  #e6e6e6; }") ,
  tags$style(type="text/css", ".control-label { line-height: 2 ; font-size: 12px;   }") ,
 tags$style(type="text/css", "#text { width: 390px ; font-size: 11px } "),
 tags$style(type="text/css", "#DataTables_Table_0 td[text*='SAL']{ background:#DCDCDC; }") 


     ),

           #  actionButton("close", "Zamknij raport" ,width = '100%' ),
             actionButton("get_data", "Generuj report" ,width =  '100%' ),
             actionButton("last_month", "Ostatni miesiÄ…c", width = '100%' ),
             dateInput('start_date', "Data poczÄ…tkowa", min = '2017-11-01', value= format(Sys.Date()-1, "%Y-%m-01")),
             dateInput('end_date', "Data końcowa", min = '2017-11-01' ,value=   format(Sys.Date()-1, "%Y-%m-%d"))







),


 mainPanel(tags$head(
  tags$style(type="text/css", ".col-sm-8 { width: 89%; }")
 ),


  div(
    verbatimTextOutput("text"), DT::dataTableOutput("results"), style = "font-size:80%" ),



tabsetPanel(
  tabPanel(
           HTML('<footer>
               <h6> kontakt: kk </h6>
                </footer>')

  ))





) 



)





 ))

我应该把verbatimTextOutput("text") 放在哪里,它负责在下载后显示日期范围以具有该日期?

【问题讨论】:

    标签: r pdf datatable shiny download


    【解决方案1】:

    您可以使用caption

    library(shiny)
    library(DT)
    ui <- fluidPage(
          dateRangeInput("daterange1", "Date range:",
                 start = "2001-01-01",
                 end   = "2010-12-31"),
          DT::dataTableOutput('table')
    ) 
    
    server <- function(input, output, session) {
    
       output$table <- renderDataTable(
          head(iris),
          caption = paste("Report Data:", input$daterange1[1], "to", input$daterange1[2] ),extensions = 'Buttons', options = list(
      dom = 'Bfrtip',
      buttons = c('pdf')
    ))
    }
    
    shinyApp(ui, server)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-08
      • 2020-12-23
      • 2015-10-03
      • 2014-05-15
      • 1970-01-01
      • 2018-08-29
      相关资源
      最近更新 更多