一段时间以来,我一直在为我的 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)。我在这里错过了什么吗?
提前谢谢了!