I'd like to automate the creation of powerpoint reports using a template. According to ReporteRs documentation, that is done with:
doc = pptx(template = '/path/to/template.pptx')
Even when attempting to load the simplest of templates I get the following error:
Error in pptx(template = '/path/to/template.pptx') :
an error occured - code[LOADDOC_ERROR].
Even the minimal example on the CRAN reference for ReporteRs results in an error for me. Here's the pdf reference and below is the example located on page 86. They first created a simple template called "template_example.pptx", then loaded the template, and made a small change to a slide. I can create the template without error, but as soon as I try to load the new template, I get the error mentioned before.
# create an doc to be used as template later
mydoc = pptx( )
mydoc = addSlide( mydoc, slide.layout = "Title and Content")
mydoc = addTitle( mydoc, "a table")
mydoc = addFlexTable( mydoc, ft1 )
mydoc = addSlide( mydoc, slide.layout = "Title and Content")
mydoc = addTitle( mydoc, "some text")
mydoc = addParagraph( mydoc, "text example" )
writeDoc( mydoc, "template_example.pptx" )
# use file pp_template_example.pptx as template
# and replace slide 1
mydoc = pptx(template = "template_example.pptx" )
mydoc = addSlide( mydoc, slide.layout = "Title and Content", bookmark = 1)
mydoc = addTitle( mydoc, "a new table")
mydoc = addFlexTable( mydoc, ft2 )
writeDoc( mydoc, "slide_replacement.pptx" )
Does anyone have insight for why this error is occurring? Thanks.
EDIT: Adding SessionInfo()
output.
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.3 (Yosemite)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_1.0.1 lubridate_1.3.3 DT_0.1 readr_0.2.2 dplyr_0.4.3 shinydashboard_0.5.1
[7] rga_0.8 httr_1.0.0 jsonlite_0.9.16 RCurl_1.95-4.7 bitops_1.0-6 openxlsx_3.0.0
[13] shiny_0.12.2 RAdwords_0.1.6 rJava_0.9-7 ReporteRs_0.8.2 ReporteRsjars_0.0.2
loaded via a namespace (and not attached):
[1] Rcpp_0.11.6 plyr_1.8.3 tools_3.2.2 digest_0.6.8 memoise_0.2.1 gtable_0.1.2 DBI_0.3.1 rstudioapi_0.3.1
[9] yaml_2.1.13 parallel_3.2.2 proto_0.3-10 stringr_1.0.0 htmlwidgets_0.5 grid_3.2.2 R6_2.1.1 reshape2_1.4.1
[17] magrittr_1.5 scales_0.2.5 htmltools_0.2.6 MASS_7.3-43 assertthat_0.1 mime_0.3 colorspace_1.2-6 xtable_1.7-4
[25] httpuv_1.3.3 labeling_0.3 stringi_0.5-5 lazyeval_0.1.10 munsell_0.4.2 rjson_0.2.15
In case anyone has this issue, follow @David Gohel's advice --> https://github.com/davidgohel/ReporteRs/issues/101
davidgohel commented on Dec 23, 2015 OK,
it seems the bug is about how we expressed the filename. This works:
pptx(template = "/Users/xxxx/Downloads/doc.pptx")
But this failed:
pptx(template = "~/Downloads/doc.pptx")