Flood or clear a range of cells
range_flood()
"floods" a range of cells with the same content.
range_clear()
is a wrapper that handles the common special case of
clearing the cell value. Both functions, by default, also clear the format,
but this can be specified via reformat
.
range_flood(ss, sheet = NULL, range = NULL, cell = NULL, reformat = TRUE) range_clear(ss, sheet = NULL, range = NULL, reformat = TRUE)
ss |
Something that identifies a Google Sheet: its file ID, a URL from
which we can recover the ID, an instance of |
sheet |
Sheet to write into, in the sense of "worksheet" or "tab". You can identify a sheet by name, with a string, or by position, with a number. |
range |
A cell range to read from. If |
cell |
The value to fill the cells in the |
reformat |
Logical, indicates whether to reformat the affected cells.
Currently googlesheets4 provides no real support for formatting, so
|
The input ss
, as an instance of sheets_id
Makes a RepeatCellRequest
:
Other write functions:
gs4_create()
,
gs4_formula()
,
range_delete()
,
range_write()
,
sheet_append()
,
sheet_write()
if (gs4_has_token()) { # create a data frame to use as initial data df <- gs4_fodder(10) # create Sheet ss <- gs4_create("range-flood-demo", sheets = list(df)) # default behavior (`cell = NULL`): clear value and format range_flood(ss, range = "A1:B3") # clear value but preserve format range_flood(ss, range = "C1:D3", reformat = FALSE) # send new value range_flood(ss, range = "4:5", cell = ";-)") # send formatting # WARNING: use these unexported, internal functions at your own risk! # This not (yet) officially supported, but it's possible. blue_background <- googlesheets4:::CellData( userEnteredFormat = googlesheets4:::new( "CellFormat", backgroundColor = googlesheets4:::new( "Color", red = 159 / 255, green = 183 / 255, blue = 196 / 255 ) ) ) range_flood(ss, range = "I:J", cell = blue_background) # range_clear() is a shortcut where `cell = NULL` always range_clear(ss, range = "9:9") range_clear(ss, range = "10:10", reformat = FALSE) # clean up gs4_find("range-flood-demo") %>% googledrive::drive_trash() }
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.