Creates an entirely new (spread)Sheet (or, in Excel-speak, workbook).
Optionally, you can also provide names and/or data for the initial set of
(work)sheets. Any initial data provided via sheets
is styled as a table,
as described in sheet_write()
.
Usage
gs4_create(name = gs4_random(), ..., sheets = NULL)
Arguments
- name
The name of the new spreadsheet.
- ...
Optional spreadsheet properties that can be set through this API endpoint, such as locale and time zone.
- sheets
Optional input for initializing (work)sheets. If unspecified, the Sheets API automatically creates an empty "Sheet1". You can provide a vector of sheet names, a data frame, or a (possibly named) list of data frames. See the examples.
Value
The input ss
, as an instance of sheets_id
See also
Wraps the spreadsheets.create
endpoint:
There is an article on writing Sheets:
Other write functions:
gs4_formula()
,
range_delete()
,
range_flood()
,
range_write()
,
sheet_append()
,
sheet_write()
Examples
gs4_create("gs4-create-demo-1")
#> ✔ Creating new Sheet: gs4-create-demo-1.
gs4_create("gs4-create-demo-2", locale = "en_CA")
#> ✔ Creating new Sheet: gs4-create-demo-2.
gs4_create(
"gs4-create-demo-3",
locale = "fr_FR",
timeZone = "Europe/Paris"
)
#> ✔ Creating new Sheet: gs4-create-demo-3.
gs4_create(
"gs4-create-demo-4",
sheets = c("alpha", "beta")
)
#> ✔ Creating new Sheet: gs4-create-demo-4.
my_data <- data.frame(x = 1)
gs4_create(
"gs4-create-demo-5",
sheets = my_data
)
#> ✔ Creating new Sheet: gs4-create-demo-5.
gs4_create(
"gs4-create-demo-6",
sheets = list(chickwts = head(chickwts), mtcars = head(mtcars))
)
#> ✔ Creating new Sheet: gs4-create-demo-6.
# Clean up
gs4_find("gs4-create-demo") %>%
googledrive::drive_trash()
#> Files trashed:
#> • gs4-create-demo-6 <id: 1KHN_hNeHf5mjyh6CpBHNm3GmXyIzvTu3J0rdr1e7gmw>
#> • gs4-create-demo-5 <id: 1xsH0aykLH4HFuLmSMMeZCD7cFHRvFabf-MFFkK3yug4>
#> • gs4-create-demo-4 <id: 14JfbxB2vcxrvTUBRld0y9xgDPFCJhO9rTxZkUfBunEc>
#> • gs4-create-demo-3 <id: 1dzDC57v7C0eSbUaXpvVw_Vqdleg1jtYkiz-D8vM3Pi4>
#> • gs4-create-demo-2 <id: 1lQs0oZR_lNJNXlYOeqMRtgpUIdOjhoeexAeZXb5BrQQ>
#> • gs4-create-demo-1 <id: 1q9BX8lh7-2yC6wq9jW0HZ4PnmF5To0SjUjIGrfNpKuc>