I have been using the excellent R package ReporteRs for a while now for my R tables and plots. David Gohel did a wonderful job here (David's site).
The problem that I am encountering is that can't make the padding function within table cells work.
Here is a part of my code:
headerCellProp = cellProperties(background.color="#ffffff",border.bottom.width = 1, border.top.width = 1, border.left.width = 0, border.right.width = 0)
headerTextProp = textProperties(font.weight="bold", color = "#000000", font.size=9 )
dataCellProp = cellProperties(border.bottom.width = 0, border.top.width = 0, border.left.width = 0, border.right.width = 0)
dataTextProp = textProperties(font.size=9, color = "#000000")
dataParProp = parProperties(padding.top = 0, padding.bottom = 0, padding.left = 10, padding.right = 5, text.align = "right")
footerCellProp = cellProperties(background.color="#ffffff",border.bottom.width = 0, border.top.width = 1, border.left.width = 0, border.right.width = 0)
mfMyDataFrame = FlexTable( data = MyDataFrame
, header.columns = FALSE
, row.names = FALSE
, cell_format = dataCellProp
, text_format = dataTextProp
)
.names = names(MyDataFrame)
headerRow = FlexRow(.names, textProp = headerTextProp, cellProp = headerCellProp )
mfMyDataFrame = addHeaderRow( mfMyDataFrame, headerRow)
footerRow = FlexRow()
footerRow[1] = FlexCell( pot( " ", format = headerTextProp ), cellProp = footerCellProp, colspan = length(.names) )
mfMyDataFrame = addFooterRow( mfMyDataFrame, footerRow)
mfMyDataFrame[,] = parProperties( padding.top = 0, padding.bottom = 0, padding.left = 10, padding.right = 5, text.align = "right" )
doc = addTitle( doc, "Table title", level = 4, stylename= "rTableLegend")
doc = addFlexTable(doc, mfMyDataFrame)
The output .docx file doesn't show any padding in the table cells (no 10 left, no 5 right). Am I missing something here?
Many thanks in advance!
From the author, David Gohel:
This was asked also on github there: https://github.com/davidgohel/ReporteRs/issues/10 It was a minor bug solved since the version 0.5.3.
Here is code that applies to cell padding:
options( "ReporteRs-fontsize" = 9 ) dataParProp = parProperties(padding.top = 0, padding.bottom = 0, padding.left = 10, padding.right = 5, text.align = "right")
mfMyDataFrame = FlexTable( data = iris, body.par.props = dataParProp, header.par.props = dataParProp )
mfMyDataFrame = setFlexTableBorders( mfMyDataFrame, inner.vertical = borderProperties( style = "none" ) , inner.horizontal = borderProperties( style = "none" ), outer.vertical = borderProperties( style = "none" ) )