简体   繁体   English

闪亮的Knitr Word找不到Word模板路径

[英]Knitr Word from shiny doesnt find Word-template path

I'm creating a shiny app that I need to export my results with R Markdown as a .docx word document utilizing a word style template 我正在创建一个闪亮的应用程序,我需要使用Word样式模板将R Markdown的结果导出为.docx Word文档。

My error code from R Markdown is: 我的Markdown的错误代码是:

pandoc.exe: reference3.docx: openBinaryFile: does not exist (No such file or >directory) Warning: Error in : pandoc document conversion failed with error 1 [No stack trace available] pandoc.exe:reference3.docx:openBinaryFile:不存在(没有此类文件或目录)警告:错误:pandoc文档转换失败,错误1 [无可用的堆栈跟踪]

I figured out that putting my local complete file path to the word style template solved. 我发现将本地完整文件路径放入文字样式模板即可解决。 The problem is: I need this for a shiny app running in a server, so put my complete file path would cause me some serious complicated things to handle inside a server. 问题是:我需要在服务器上运行的闪亮应用程序,因此,将完整的文件路径放入服务器中会导致一些严重的复杂事情。

Why cant I just call for: 为什么我不能要求:

reference_docx: reference3.docx Since my word style template it is in the same folder as all my other files? reference_docx:reference3.docx由于我的文字样式模板与所有其他文件位于同一文件夹中?

My YAML header: 我的YAML标头:

---
title: "Report DIC"
author: "Artur"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output: 
    word_document: 
      reference_docx: reference3.docx
      highlight: NULL

---

Obs: I'm generating my file from a flexdashboard downloadHandler, here's the code from it: Obs:我正在从flexdashboard downloadHandler生成文件,这是它的代码:

output$downloadReport <- downloadHandler(
      filename = "Resultados_Report.docx",
      content = function(file){

        tempReport <- file.path(tempdir(), report.Rmd")

        file.copy(report.Rmd, 
                  tempReport, overwrite = TRUE)

        params <- list( anova = "Values",
                        nomes = "Names")

        rmarkdown::render(tempReport, output_file = file,
                          output_format = "word_document",
                          params = params,
                          envir = new.env(parent = globalenv()))

        }
  )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM