Deletes one or more (work)sheets from a (spread)Sheet.
Arguments
- ss
Something that identifies a Google Sheet:
its file id as a string or
drive_id
a URL from which we can recover the id
a one-row
dribble
, which is how googledrive represents Drive filesan instance of
googlesheets4_spreadsheet
, which is whatgs4_get()
returns
Processed through
as_sheets_id()
.- sheet
Sheet to delete, in the sense of "worksheet" or "tab". You can identify a sheet by name, with a string, or by position, with a number. You can pass a vector to delete multiple sheets at once or even a list, if you need to mix names and positions.
Value
The input ss
, as an instance of sheets_id
See also
Makes an DeleteSheetsRequest
:
Other worksheet functions:
sheet_add()
,
sheet_append()
,
sheet_copy()
,
sheet_properties()
,
sheet_relocate()
,
sheet_rename()
,
sheet_resize()
,
sheet_write()
Examples
if (gs4_has_token()) {
ss <- gs4_create("delete-sheets-from-me")
sheet_add(ss, c("alpha", "beta", "gamma", "delta"))
# get an overview of the sheets
sheet_properties(ss)
# delete sheets
sheet_delete(ss, 1)
sheet_delete(ss, "gamma")
sheet_delete(ss, list("alpha", 2))
# get an overview of the sheets
sheet_properties(ss)
# clean up
gs4_find("delete-sheets-from-me") %>%
googledrive::drive_trash()
}
#> ✔ Creating new Sheet: delete-sheets-from-me.
#> ✔ Adding 4 sheets to delete-sheets-from-me:
#> • alpha
#> • beta
#> • gamma
#> • delta
#> ✔ Deleting 1 sheet from delete-sheets-from-me:
#> • Sheet1
#> ✔ Deleting 1 sheet from delete-sheets-from-me:
#> • gamma
#> ✔ Deleting 2 sheets from delete-sheets-from-me:
#> • alpha
#> • beta
#> File trashed:
#> • delete-sheets-from-me
#> <id: 1VXY_x1wjIZIGlJnm2upA4JXxt4n8YTA2SvgSq5dSiDg>