8

I am using ReporteRs package in R to create a report. I have a table which has 13 columns and I would like it to go in a landscape orientation. Otherwise some columns will be cut down from the table. I am wondering whether it is possible to specify this in ReporteRs for a specific FlexTable object? All the other tables and texts come in portrait format. My apologies for not giving a reproducible example. Thank you in advance.

Marat Talipov
  • 13,064
  • 5
  • 34
  • 53
JeanVuda
  • 1,738
  • 14
  • 29

1 Answers1

5

You can do it with addSection:

library(ReporteRs)
doc = docx()
doc = addSection( doc, landscape = T ) 
doc = addFlexTable( doc, FlexTable( mtcars) )
doc = addSection( doc, landscape = F ) 
writeDoc( doc, "test.docx")

Another solution would be to create an empty Word document with landscape orientation and then to use it as a template:

library(ReporteRs)
doc = docx(template = "your_landscape_doc.docx")
doc = addFlexTable( doc, FlexTable( mtcars) )
writeDoc( doc, "test.docx")
David Gohel
  • 9,180
  • 2
  • 16
  • 34
  • The closing `addSection()` call is important and landscape doesn't work for me otherwise. – Matt May 14 '18 at 20:22