doc.filename = "addSlide_example.pptx"
options( "ReporteRs-fontsize" = 24 )
doc = pptx( title = "title" )
# add a slide with layout "Title Slide"
doc = addSlide( doc, slide.layout = "Title Slide" )
#set the main title
doc = addTitle( doc, "Presentation title" )
#set the sub-title
doc = addSubtitle( doc , "This document is generated with ReporteRs.")
# add a slide with layout "Title and Content" then add content
doc = addSlide( doc, slide.layout = "Title and Content" )
doc = addTitle( doc, "Iris sample dataset", level = 1 )
doc = addFlexTable( doc, vanilla.table( iris[ 1:10,] ) )
# add a slide with layout "Two Content" then add content
doc = addSlide( doc, slide.layout = "Two Content" )
doc = addTitle( doc, "Two Content demo", level = 1 )
doc = addFlexTable( doc, vanilla.table( iris[ 46:55,] ) )
doc = addParagraph(doc, "Hello Word!" )
# to see available layouts :
slide.layouts( doc )
writeDoc( doc, file = doc.filename )
# demo slide replacement --------
# define 2 FlexTables
ft1 = vanilla.table( mtcars[1:6,] , add.rownames = TRUE )
ft2 = vanilla.table( iris[1:10,], add.rownames = TRUE )
# 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" )
Run the code above in your browser using DataLab