I'm trying to update multiple cell values in an xlsx sheet using setCellValue(cell, value)
function from xlsx
package. Its working fine only when I gave one cell location, If I'm keeping the code under for()
loop and concatenating the cell location, getting below error.
Code:
fn <- "C:/TestR.xlsx"
sn <- "ExtractOFDBItem"
wb <- loadWorkbook(fn)
sheets <- getSheets(wb)
sheet <- sheets[[sn]]
rows <- getRows(sheet)
cells <- getCells(rows)
for (i in 1:10){
cellLocation <- sprintf("cells$`%s.12`", i)
setCellValue(cellLocation, "There is difference in responses, Please check the Logs")
saveWorkbook(wb, fn)
}
Error:
Error in .jcall(cell, "V", "setCellValue", value) :
RcallMethod: cannot determine object class
Can anyone help me with the code so that I can update multiple cells in a column with 'i' number of rows?