【问题标题】:how to format contents of data frame using openxlsx::writedata如何使用 openxlsx::writedata 格式化数据框的内容
【发布时间】:2021-05-04 04:54:33
【问题描述】:

我使用以下代码将数据从 R 写入 excel。样式仅针对标头实现,而不针对相应的值实现。如何根据需要更改样式,包括缩进、粗体、字体大小等;

h1=openxlsx::createStyle(fontSize = 12, fontColour = "#FFFFFF", halign = "center",
                         fgFill = "#4F81BD", border = "TopBottomLeftRight", borderColour = "#4F81BD", 
                         valign = "center", textDecoration = "bold",wrapText = FALSE)



openxlsx::writeData(wb1,'sheet1', df1,startCol = 4, startRow = 6,headerStyle =h1,borders="all", borderColour = "black",)
openxlsx::writeData(wb1,'sheet2', df2,startCol = 5, startRow = 6,headerStyle =h1,borders="all", borderColour = "black",)

【问题讨论】:

  • 图片尚未上传。
  • 图片上传,请推荐
  • 对上述请求有什么建议吗?
  • 您能否附上图片所代表内容的标题或解释?是否希望标题下方行中的值与标题的样式相同?

标签: r excel


【解决方案1】:

谢谢,我通过 usinf justify command "data=format(data, width = name.width, justify = "centre") 找到了解决方案

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-30
    • 2016-07-18
    • 1970-01-01
    • 1970-01-01
    • 2018-10-23
    • 2019-11-20
    • 1970-01-01
    • 2022-01-20
    相关资源
    最近更新 更多