How do I set the value of a specific cell using xlsx (R package)?

前端 未结 1 2085
栀梦
栀梦 2021-01-14 03:57

I\'m trying to set the value of a specific cell in xlsx. I\'m doing this to add a title for the data frame that I added in Excel, but I can\'t figure it out. I tried c

相关标签:
1条回答
  • 2021-01-14 04:42

    Without benefit of seeing your code and knowing exactly what you are trying to do, I suggest trying

    setCellValue(cell, value)
    

    For example, starting from scratch and creating a new excel file:

    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
    
    0 讨论(0)
提交回复
热议问题