All,

I have an excel template and I would like to edit the data in the template. I am able to do it with the loops construct, but I know loops are inefficient. So, I am trying to use the "apply" family functions and could use some help. Here is some sample code :

```
suppressPackageStartupMessages(library(readxl))
suppressPackageStartupMessages(library(openxlsx))
TemplateFilePath <- paste('C:', 'Test1.xlsx', sep = '\\')
# Get Handle to Template file
wb <- loadWorkbook(TemplateFilePath)
SpecialRows <- list(30,31,32,33)
SummaryData <- c(sum(1:10), sum(2:20), sum(3:30), sum(4:40))
WbObjectList <- list(rep('wb', length(SummaryData)))
SheetNamesList <- list(rep('Test'), length(SummaryData))
ColsList <- list(rep(1), length(SummaryData))
Res3 <- lapply(1:length(SummaryData),
function(i)
{
writeData(WbObjectList[i], SheetNamesList[i], x = (SummaryData[[i]]), startCol = ColsList[i], startRow = SpecialRows[i])
addStyle(WbObjectList[i], SheetNamesList[i], styleT, cols = ColsList[i], rows = SpecialRows[i])
}
)
```

Please note that the functions writeData an addstyle are from the openxlsx package

This results in the following error:

**Error in writeData(WbObjectList[i], SheetNamesList[i], x = (SummaryData[[i]]), :
(list) object cannot be coerced to type 'integer'**

Best

uday