4

I want to indent a (flex)table created with the ReporterRs package. Here's an example:

library(ReporteRs)

df <- data.frame(Column1 = 1:5, Column2 = c("a","b","c","d","e"))
Mydoc = docx(title="A testdoc for testing tables")
options('ReporteRs-fontsize'=10, 'ReporteRs-default-font'='Arial')
FTab = FlexTable( data = df, add.rownames = FALSE, header.columns = TRUE,  
                  body.text.props = textProperties( font.size = 10,font.family = "Arial" ),
                  header.text.props = textProperties( font.size = 10,font.family = "Arial", font.weight = "bold"))
FTab = setFlexTableBorders(FTab,inner.vertical = borderNone(),inner.horizontal = borderNone(),
                           outer.vertical = borderNone(), 
                           outer.horizontal = borderProperties(color = "black", style = "solid", width = 1))
Mydoc = addFlexTable(Mydoc, FTab)

nu <- format(Sys.time(), "%Y%m%d%H%M")
writeDoc(Mydoc, paste0("testreport_",nu,".docx"))

This creates a docx with a left aligned table. I want the table to move 1.5 cm to the right. So no center or right alignment, but an indentation of 1.5 cm. Is this possible? For text, I can use a pre-defined style that indents 1.5 cm, but for tables that doesn't seem possible. Or is it?

As a workaround, I could add an extra column at the left, without any borders or text. But I prefer a neat solution.

RHA
  • 3,677
  • 4
  • 25
  • 48

1 Answers1

0

From the package documentation, unless you want to write a patch, it seems you'd better go with the invisible column:

Function addFlexTable

add FlexTable to document objects.

Word and html document

Add a FlexTable object in a document object with the function addFlexTable.

Expected arguments are:

  • the document object
  • the FlexTable object
  • eventually a parProperties object to define alignement. Note that with docx objects, only alignment will be used, if you’d like to add space around a table, specify padding on preceding and or following paragraph.
Community
  • 1
  • 1
HubertL
  • 19,246
  • 3
  • 32
  • 51
  • Yes, I'd seen that. But I was hoping there would be a way by specifying padding or some smart tweak. And I would love to write a patch but am afraid my programming skills are not good enough. – RHA Oct 26 '16 at 04:57