clearRange-methods

0th

Percentile

Clearing cell ranges in a workbook

Clears cell ranges in a '>workbook.

Keywords
methods, utilities
Usage
# S4 method for workbook,numeric
clearRange(object, sheet, coords)
  # S4 method for workbook,character
clearRange(object, sheet, coords)
Arguments
object

The '>workbook to use

sheet

The name or index of the worksheet in which to clear cell ranges

coords

Numeric vector of length 4 or numeric matrix with 4 columns where the elements of the vector or rows in the matrix refer to the coordinates of the top-left and bottom-right corners of the ranges to clear. I.e. a vector or each row specifies the coordinates {top row, left column, bottom row, right column}. You may use aref2idx to generate such a matrix.

Details

Clearing a cell range means to clear all the cells associated with that range.

See Also

'>workbook, clearSheet, clearNamedRegion, clearRangeFromReference, clearSheet

Aliases
  • clearRange
  • clearRange-methods
  • clearRange,workbook,numeric-method
  • clearRange,workbook,character-method
Examples
# NOT RUN {
# mtcars xlsx file from demoFiles subfolder of 
# package XLConnect
demoExcelFile <- system.file("demoFiles/mtcars.xlsx", 
                             package = "XLConnect")

# Load workbook
wb <- loadWorkbook(demoExcelFile)

# Clear range from top left corner (4,2) ^= B4 to
# bottom right corner (6,4) ^= D6
clearRange(wb, sheet = "mtcars", coords = c(4, 2, 6, 4))

# Clear two ranges in one go ...
mat = matrix(c(5, 1, 6, 4, 5, 7, 7, 9), ncol = 4,
             byrow = TRUE)
clearRange(wb, sheet = "mtcars", coords = mat)

# The above is equivalent to ...
clearRange(wb, sheet = "mtcars",
           coords = aref2idx(c("A5:D6", "G5:I7")))
           
# This in turn is the same as ...
clearRangeFromReference(wb, reference = c("mtcars!A5:D6",
                        "mtcars!G5:I7"))
# }
Documentation reproduced from package XLConnect, version 0.2-14, License: GPL-3

Community examples

Looks like there are no examples yet.