Java 如何找到 Google 电子表格 ID?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36061433/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to do I locate a Google SpreadSheet ID?
提问by Boom3k
https://developers.google.com/apps-script/guides/rest/api#parameter_and_return_types
https://developers.google.com/apps-script/guides/rest/api#parameter_and_return_types
When using the Google Execution Api for Java, the ID of the spreadsheet isn't very easy to understand. Here is the code snippet:
使用 Google Execution Api for Java 时,电子表格的 ID 不是很容易理解。这是代码片段:
// Initialize parameters for that function.
String sheetId = "<ENTER_ID_OF_SPREADSHEET_TO_EXAMINE_HERE>";
List<Object> params = new ArrayList<Object>();
params.add(sheetId);
Any Ideas on how to locate this. I run the Sheets api to return the id of a SpreadSheet but it returns a link, and when I use the https://spreadsheets.google.com/feeds/spreadsheets/STRINGor just the STRINGitself I still get: "code" : 404, "errors" : [ { "domain" : "global", "message" : "Requested entity was not found.", "reason" : "notFound"
关于如何找到它的任何想法。我运行 Sheets api 以返回 SpreadSheet 的 ID,但它返回一个链接,当我使用https://spreadsheets.google.com/feeds/spreadsheets/ STRING或仅使用STRING本身时,我仍然得到:“代码” :404,“错误”:[{“域”:“全局”,“消息”:“未找到请求的实体。”,“原因”:“未找到”
采纳答案by Boom3k
Found this deep inside the Apps Script API reference.
在 Apps Script API 参考中找到了这一点。
A spreadsheet ID can be extracted from its URL. For example, the spreadsheet ID in the URL https://docs.google.com/spreadsheets/d/abc1234567/edit#gid=0is "abc1234567".
可以从其 URL 中提取电子表格 ID。例如,URL https://docs.google.com/spreadsheets/d/abc1234567/edit#gid=0 中的电子表格 ID是“abc1234567”。
回答by Sam Evers
https://developers.google.com/sheets/api/guides/concepts
https://developers.google.com/sheets/api/guides/concepts
states that:
指出:
Every API method requires a spreadsheetId parameter which is used to identify which spreadsheet is to be accessed or altered. This ID is the value between the "/d/" and the "/edit" in the URL of your spreadsheet. For example, consider the following URL that references a Google Sheets spreadsheet:
每个 API 方法都需要一个电子表格 ID 参数,该参数用于标识要访问或更改的电子表格。此 ID 是电子表格 URL 中“/d/”和“/edit”之间的值。例如,考虑以下引用 Google Sheets 电子表格的 URL:
https://docs.google.com/spreadsheets/d/1qpyC0XzvTcKT6EISywvqESX3A0MwQoFDE8p-Bll4hps/edit#gid=0
The ID of this spreadsheet is 1qpyC0XzvTcKT6EISywvqESX3A0MwQoFDE8p-Bll4hps.
此电子表格的 ID 是1qpyC0XzvTcKT6EISywvqESX3A0MwQoFDE8p-Bll4hps。
So I just pulled up my spreadsheet and looked at the URL to find my ID.
所以我只是调出我的电子表格并查看 URL 以找到我的 ID。
Hope this helps!
希望这可以帮助!
回答by Jeff Sparksworthy
I just created a hyperlink to the sheets and then copied that hyperlink to a text file and the link line shows the GID.
我刚刚创建了一个指向工作表的超链接,然后将该超链接复制到一个文本文件中,并且链接行显示了 GID。
Then I created a pull down list in A52 and then made =IF() logic to go to the GIDs to go to those sheets.
然后我在 A52 中创建了一个下拉列表,然后使 =IF() 逻辑转到 GID 转到那些工作表。
=IF(A52="47QTCK18D0001",HYPERLINK("#gid=0","47QTCK18D0001"),IF(A52="47QTCK18D0002",HYPERLINK("#gid=1049871492","47QTCK18D0002") ....
=IF(A52="47QTCK18D0001",HYPERLINK("#gid=0","47QTCK18D0001"),IF(A52="47QTCK18D0002",HYPERLINK("#gid=1049871492","47QTCK2") ...