简体   繁体   English

如何在Google Apps脚本中获取发布到网络电子表格的ID

[英]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. 然后,脚本将它们发布到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. 我无法获得的是ID,该ID将允许我获取其Web版本的URL。

A regular spreadsheet id looks like this: 常规电子表格ID如下所示:

1N8h00iN2L7aaUbI9TYRWioaZHjHNSc_vNucCbVADj1o 1N8h00iN2L7aaUbI9TYRWioaZHjHNSc_vNucCbVADj1o

And a published to the web id looks like this: 发布到网络的ID如下所示:

2PACX-1vTPSkv4Rz7CqwabTTfxa3xcVF-Gzxu7IboLyLkfoShP2d3qdX8o0qdvk5d_nWZD2rq43E2LXmVAm5HI 2PACX-1vTPSkv4Rz7CqwabTTfxa3xcVF-Gzxu7IboLyLkfoShP2d3qdX8o0qdvk5d_nWZD2rq43E2LXmVAm5HI

(longer, and it starts with 2PACX-) (更长,它以2PACX-开头)

Anybody know how to? 有人知道怎么做吗?

Thanks in advance. 提前致谢。

You want to retrieve URL from the web published spreadsheet using file ID. 您要使用文件ID从网络发布的电子表格中检索URL。 If my understanding is correct, how about this answer? 如果我的理解是正确的,那么这个答案呢? Unfortunately, "publishedLink" cannot be retrieved by Drive API v3. 不幸的是,Drive API v3无法检索“ publishedLink”。 "publishedLink" got to not be able to be used from Drive API v3. 必须从Drive API v3中不能使用“ publishedLink”。 Furthermore now, Drive API v2 also cannot be used anymore. 此外,现在也无法再使用Drive API v2。 So it is required to create the link manually. 因此,需要手动创建链接。

When the spreadsheet is published to Web, you retrieve URL like as follows. 当电子表格发布到Web时,您将检索URL,如下所示。

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. 当您想通过文件ID使用URL时,请使用以下URL。 You can use both URLs. 您可以使用两个URL。

Pattern 1: 模式1:

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

Pattern 2: 模式2:

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

If I misunderstand your question, I'm sorry. 如果我误解了您的问题,对不起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在谷歌应用程序脚本中获取文件ID - How to get file ID in google apps scripts 如何使用 Google Apps 脚本引用外部电子表格 - How to reference an external spreadsheet with Google Apps Scripts Google Apps脚本:获取电子表格的URL并通过邮件发送 - Google apps scripts : get the URL of the spreadsheet and send it by mail 如何在 Google Apps Script 电子表格嵌入脚本中使用确认按钮? - How to use a confirmation button in Google Apps Script spreadsheet embedded scripts? 如何使用谷歌应用脚本应用电子表格过滤器? - How to apply filters of spreadsheet using google apps scripts? 如何在电子表格中获取应用程序脚本的 ID - How to get the ID of the apps script inside a spreadsheet 通过 Google Apps Scripts #2 发布 Google 电子表格 - Publish a Google Spreadsheet through Google Apps Scripts #2 通过 Google Apps Scripts 发布 Google 电子表格 - publish a Google Spreadsheet through Google Apps Scripts 如何获取链接/绑定到 Google 电子表格的 Google Apps 脚本项目 ID - How to get Google Apps Script project ID linked/bound to a Google Spreadsheet 如何将多个谷歌表格发布到 web 并使用 Apps 脚本获取 pubHTML 链接? - How to make a multiple google sheets published to web and get the pubHTML link using Apps Script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM