I need to generate multiple reports from a single docx template - incredibly easy thanks to this package (thanks!). At a later stage, I would like to be able to add figures, text, or tables at bookmarks generated while modifying the original docx template. I think, in principle, this is a similar request as Issue 145. Perhaps the simple way to do this is to have a function like addBookmark(). Simple example follows. I commented out my pseudo-code for how such a function might appear. Thanks in advance for your help!
library( ReporteRs )
library( ggplot2 )
# Template from http://davidgohel.github.io/ReporteRs/files/word/word_bookmark_template.docx
mydoc <- docx( template = "files/word/word_bookmark_template.docx" )
authorList <- c("Randy", "Ted", "Marvin", "Norton")
# replace bookmarks 'AUTHOR'
for(i in authorList)
mydoc <- addParagraph( mydoc
, value = i
, stylename = "small"
, bookmark = "AUTHOR" )
# add bookmark value "BookmarkMe", here:
#mydoc <- addBookmark( mydoc
# , value = "BookmarkMe" )
writeDoc( mydoc, file = paste0("files/word/word_replacement-", i, ".docx"))
}
# Later, for each report, I can replace bookmarks 'BookmarkMe'
mydoc <- docx( "files/word/word_bookmark-Norton.docx" )
mydoc <- addPlot( mydoc, fun = print, x = myplot1, bookmark = "BookmarkMe" )
writeDoc( mydoc, file = "files/word/word_replacement-Norton.docx")
I need to generate multiple reports from a single docx template - incredibly easy thanks to this package (thanks!). At a later stage, I would like to be able to add figures, text, or tables at bookmarks generated while modifying the original docx template. I think, in principle, this is a similar request as Issue 145. Perhaps the simple way to do this is to have a function like addBookmark(). Simple example follows. I commented out my pseudo-code for how such a function might appear. Thanks in advance for your help!