Get the linked Google Sheet chart reference from a chart element
Source:R/element_generics.R
get_linked_sheet.RdResolves the chart's spreadsheetId and chartId from the raw API node
back to a chart_id object. The function makes one API call to the Google
Sheets API to identify which sheet tab within the spreadsheet contains the
chart, so the returned chart_id carries spreadsheet_id, sheet_id, and
chart_id.
This is useful for round-tripping: extract the reference from an existing
linked chart element and pass it to add_linked_chart() to insert it on
another slide.
Only defined for chart_element objects; calling on any other element type
errors with an informative message.
Examples
if (FALSE) {
ps <- register_presentation(id = "YOUR_PRESENTATION_ID", set_active = FALSE)
slide_obj <- on_slide_number(1, ps)
el <- get_elements(slide_obj, type = "chart")[[1]]
cid <- get_linked_sheet(el)
cid@spreadsheet_id
cid@chart_id
}