【问题标题】:How do I set the value of a specific cell using xlsx (R package)?如何使用 xlsx(R 包)设置特定单元格的值?
【发布时间】:2014-07-09 04:50:19
【问题描述】:

我正在尝试在 xlsx 中设置特定单元格的值。我这样做是为我在 Excel 中添加的数据框添加标题,但我无法弄清楚。我尝试了createCellscreateRowsgetCellsgetRows,但尽管阅读了文档,但我似乎无法让它们中的任何一个工作。

【问题讨论】:

  • 您能否发布您创建的代码以到达要添加标题的位置?

标签: r package xlsx


【解决方案1】:

如果没有看到您的代码并确切知道您要做什么,我建议您尝试一下

setCellValue(cell, value)

例如,从头开始,新建一个excel文件:

wb    <- createWorkbook(type="xlsx")           # create an empty workbook
sheet <- createSheet(wb, sheetName="Sheet1")   # create an empty sheet 
rows  <- createRow(sheet, rowIndex=1:10)       # 10 rows
cells <- createCell(rows, colIndex=1:6)        # 6 columns in each row
setCellValue(cells[[1,2]], "Data Frame Title Goes Here")   # put in Row 1, Column 2

【讨论】:

    猜你喜欢
    • 2012-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多