简体   繁体   中英

How to get the id for a published to the web spreadsheet in google apps scripts

I have a script that takes rows from a spreadsheet, and creates individual spreadsheet files for each row. Then the script publishes them to the web.

What I'm not able to get is the id that will allow me to get an url for a web version of it.

A regular spreadsheet id looks like this:

1N8h00iN2L7aaUbI9TYRWioaZHjHNSc_vNucCbVADj1o

And a published to the web id looks like this:

2PACX-1vTPSkv4Rz7CqwabTTfxa3xcVF-Gzxu7IboLyLkfoShP2d3qdX8o0qdvk5d_nWZD2rq43E2LXmVAm5HI

(longer, and it starts with 2PACX-)

Anybody know how to?

Thanks in advance.

You want to retrieve URL from the web published spreadsheet using file ID. If my understanding is correct, how about this answer? Unfortunately, "publishedLink" cannot be retrieved by Drive API v3. "publishedLink" got to not be able to be used from Drive API v3. Furthermore now, Drive API v2 also cannot be used anymore. So it is required to create the link manually.

When the spreadsheet is published to Web, you retrieve URL like as follows.

https://docs.google.com/spreadsheets/d/e/2PACX-1vTPSkv4Rz7CqwabTTfxa3xcVF-Gzxu7IboLyLkfoShP2d3qdX8o0qdvk5d_nWZD2rq43E2LXmVAm5HI/pubhtml

When you want to use the URL using file ID, please use the following URL. You can use both URLs.

Pattern 1:

https://docs.google.com/spreadsheet/pub?key=### fileId ###

Pattern 2:

https://docs.google.com/spreadsheets/d/### fileId ###/pubhtml

If I misunderstand your question, I'm sorry.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM