My first attempt was raw html, but that clearly didn't work.
I found that I'm supposed to use rich text, so I tried:
function youtubeLink(yt_id, start_stamp, end_stamp) {
const start_secs = toSecs(start_stamp)
const end_secs = toSecs(end_stamp)
const href = `https://www.youtube.com/embed/${yt_id}?start=${start_secs}&end=${end_secs}`
return (
SpreadsheetApp.newRichTextValue()
.setText("Youtube Link")
.setLinkUrl(href)
.build()
)
}
I'm calling with:
=youtubeLink(A1,A2,A3)
But that didn't work at all. The field just stayed blank.
I tried with a range, but got a circular reference. It seems like this should be easy. Not sure what I'm missing.
This works, but it is auto-formated and the link text is the same as the link:
function youtubeLink(yt_id, start_stamp, end_stamp) {
const start_secs = toSecs(start_stamp)
const end_secs = toSecs(end_stamp)
return (`https://www.youtube.com/embed/${yt_id}?start=${start_secs}&end=${end_secs}`)
}