sheet_copy | R Documentation |
Copies a (work)sheet, within its current (spread)Sheet or to another Sheet.
sheet_copy(
from_ss,
from_sheet = NULL,
to_ss = from_ss,
to_sheet = NULL,
.before = NULL,
.after = NULL
)
from_ss |
Something that identifies a Google Sheet:
Processed through |
from_sheet |
Sheet to copy, in the sense of "worksheet" or "tab". You can identify a sheet by name, with a string, or by position, with a number. Defaults to the first visible sheet. |
to_ss |
The Sheet to copy to. Accepts all the same types of input as
|
to_sheet |
Optional. Name of the new sheet, as a string. If you don't
specify this, Google generates a name, along the lines of "Copy of blah".
Note that sheet names must be unique within a Sheet, so if the automatic
name would violate this, Google also de-duplicates it for you, meaning you
could conceivably end up with "Copy of blah 2". If you have better ideas
about sheet names, specify |
.before, .after |
Optional specification of where to put the new sheet. Specify, at most, one of |
The receiving Sheet, to_ ss
, as an instance of sheets_id
.
If the copy happens within one Sheet, makes a DuplicateSheetRequest
:
If the copy is from one Sheet to another, wraps the
spreadsheets.sheets/copyTo
endpoint:
and possibly makes a subsequent UpdateSheetPropertiesRequest
:
Other worksheet functions:
sheet_add()
,
sheet_append()
,
sheet_delete()
,
sheet_properties()
,
sheet_relocate()
,
sheet_rename()
,
sheet_resize()
,
sheet_write()
ss_aaa <- gs4_create(
"sheet-copy-demo-aaa",
sheets = list(mtcars = head(mtcars), chickwts = head(chickwts))
)
# copy 'mtcars' sheet within existing Sheet, accept autogenerated name
ss_aaa %>%
sheet_copy()
# copy 'mtcars' sheet within existing Sheet
# specify new sheet's name and location
ss_aaa %>%
sheet_copy(to_sheet = "mtcars-the-sequel", .after = 1)
# make a second Sheet
ss_bbb <- gs4_create("sheet-copy-demo-bbb")
# copy 'chickwts' sheet from first Sheet to second
# accept auto-generated name and default location
ss_aaa %>%
sheet_copy("chickwts", to_ss = ss_bbb)
# copy 'chickwts' sheet from first Sheet to second,
# WITH a specific name and into a specific location
ss_aaa %>%
sheet_copy(
"chickwts",
to_ss = ss_bbb, to_sheet = "chicks-two", .before = 1
)
# clean up
gs4_find("sheet-copy-demo") %>%
googledrive::drive_trash()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.