2

一段时间以来,我一直在为我的 R 表和绘图使用出色的 R 包 ReporteRs。David Gohel 在这里(大卫的网站)做得很好。

我遇到的问题是无法使表格单元格中的填充功能起作用。

这是我的代码的一部分:

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) 

输出 .docx 文件未在表格单元格中显示任何填充(左侧没有 10,右侧没有 5)。我在这里错过了什么吗?

提前谢谢了!

4

1 回答 1

2

来自作者大卫·戈赫尔:

这也在 github 上被问到: https ://github.com/davidgohel/ReporteRs/issues/10 这是自 0.5.3 版以来解决的一个小错误。

以下是适用于单元格填充的代码:

options("ReporteRs-fontsize" = 9) dataParProp = parProperties(padding.top = 0, padding.bottom = 0, padding.left = 10, padding.right = 5, text.align = "right")

mfMyDataFrame = FlexTable(数据 = 虹膜,body.par.props = dataParProp,header.par.props = dataParProp)

mfMyDataFrame = setFlexTableBorders(mfMyDataFrame,inner.vertical =borderProperties(style =“none”),inner.horizo​​ntal =borderProperties(style =“none”),outer.vertical =borderProperties(style =“none”))

于 2014-05-26T00:10:44.930 回答