我试图在xlsx中设置特定单元格的值。我这样做是为我在Excel中添加的数据框添加标题,但我无法弄明白。我尝试了createCells
,createRows
,getCells
和getRows
,但我无法在阅读文档的情况下使其中任何一个工作。
答案 0 :(得分:9)
如果没有看到您的代码并准确了解您要执行的操作,我建议您尝试
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