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

别等时光非礼了梦想. 提交于 2019-12-04 01:32:50

问题


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 createCells, createRows, getCells and getRows, but I can't seem to get any of them to work despite reading the documentation.


回答1:


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


来源:https://stackoverflow.com/questions/24621544/how-do-i-set-the-value-of-a-specific-cell-using-xlsx-r-package

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!