Learn R Programming

openxlsx (version 1.0.3)

deleteData: Delete cell data

Description

Remove contents and styling from a cell.

Usage

deleteData(wb, sheet, cols, rows, gridExpand = FALSE)

Arguments

wb
A workbook object
sheet
A name or index of a worksheet
rows
Rows to delete data from.
cols
columns to delete data from.
gridExpand
If TRUE, all data in rectangle min(rows):max(rows) X min(cols):max(cols) will be removed.

Examples

Run this code
## load a workbook
wb <- createWorkbook("Alex")
addWorksheet(wb, "Worksheet 1")
x <- data.frame(matrix(runif(200), ncol = 10))
names(x) <- paste("Variable", 1:10)
writeData(wb, sheet = 1, x = x, startCol = 2, startRow = 3, colNames = TRUE)

## delete cell contents
deleteData(wb, sheet = 1, cols = 3:5, rows = 5:7, gridExpand = TRUE)
deleteData(wb, sheet = 1, cols = 7:9, rows = 5:7, gridExpand = TRUE)

saveWorkbook(wb, "deleteDataExample.xlsx", overwrite = TRUE)

Run the code above in your browser using DataLab