inst/apps/leistungstest_variable/dokumentation/server_gen_reports.R

# test report template-----------------
output$test_report <- downloadHandler(
#https://shiny.rstudio.com/gallery/download-knitr-reports.html

  filename = function(){
    paste('Leistungstest_xy_',
          Sys.Date(),
          switch(
            input$report_format_type,
            pdf = ".pdf",
            word = ".docx"
          ),
          sep = "")
  },

  content = function(file) {
    params <- list(ostit = ostit,
                   report_format_type = input$report_format_type
                   )

    rmarkdown::render(
      file.path("report_templates", "report_leistungstest.Rmd"),
      params = params,
      envir = new.env(parent = globalenv()),
      output_file = file,
      output_format =
      switch(
        input$report_format_type ,
        pdf = pdf_document(number_sections = TRUE),
        word = word_document()
      ),
      encoding = "UTF-8"
    )
  }

)
stephanGit/leistungstests documentation built on May 30, 2019, 3:14 p.m.