Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

deleteData

Delete cell data


Description

Delete 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

cols

columns to delete data from.

rows

Rows to delete data from.

gridExpand

If TRUE, all data in rectangle min(rows):max(rows) X min(cols):max(cols) will be removed.

Author(s)

Alexander Walker

Examples

## write some data
wb <- createWorkbook()
addWorksheet(wb, "Worksheet 1")
x <- data.frame(matrix(runif(200), ncol = 10))
writeData(wb, sheet = 1, x = x, startCol = 2, startRow = 3, colNames = FALSE)

## delete some data
deleteData(wb, sheet = 1, cols = 3:5, rows = 5:7, gridExpand = TRUE)
deleteData(wb, sheet = 1, cols = 7:9, rows = 5:7, gridExpand = TRUE)
deleteData(wb, sheet = 1, cols = LETTERS, rows = 18, gridExpand = TRUE)
## Not run: 
saveWorkbook(wb, "deleteDataExample.xlsx", overwrite = TRUE)

## End(Not run)

openxlsx

Read, Write and Edit xlsx Files

v4.2.3
MIT + file LICENSE
Authors
Philipp Schauberger [aut, cre], Alexander Walker [aut], Luca Braglia [ctb], Joshua Sturm [ctb]
Initial release
2020-10-26

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.