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

I am trying to set the value of a specific cell in xlsx. I am doing this to add a header for the data frame that I added in Excel, but I cannot figure it out. I tried to createCells, createRows, getCellsand getRows, but I can not get them to work, despite reading the documentation.

+4
source share
1 answer

Unable to see your code and know 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
+8
source

Source: https://habr.com/ru/post/1547510/


All Articles