if (FALSE) {
# Load workbook (create if not existing)
wb <- loadWorkbook("createName.xlsx", create = TRUE)
# Create a worksheet named 'mtcars'
createSheet(wb, name = "mtcars")
# Create a named region called 'mtcars' on the sheet called 'mtcars'
createName(wb, name = "mtcars", formula = "mtcars!$A$1")
# Write built-in data set 'mtcars' to the above defined named region
writeNamedRegion(wb, mtcars, name = "mtcars")
# Save workbook
saveWorkbook(wb)
# clean up
file.remove("createName.xlsx")
}
Run the code above in your browser using DataLab