繁体   English   中英

如何读取通过Java与Google API公开的电子表格?

[英]How to read spreadsheet which made public using Java with google api?

我想从pubhtml中的一个公共电子表格中读取数据。

如何使用google-api阅读上述电子表格?

我已经尝试了以下步骤,但出现错误:

  1. 我将Google API文档与电子表格ID一起使用。

  2. 例:

sheet-id- 2PACX-1vTe-
Cmpii1CsnufmSER7ObEuhBb4TGO29RRwcEAQjW8PYkHKQMfUvriPk2LPXyCm8HMKCIvNFXSqJkU
  1. 错误:
Exception in thread "main" com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
{
  "code" : 404,
  "errors" : [ {
    "domain" : "global",
    "message" : "Requested entity was not found.",
    "reason" : "notFound"
  } ],
  "message" : "Requested entity was not found.",
  "status" : "NOT_FOUND"
}
    at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1065)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
    at Quickstart.main(Quickstart.java:108)

Process finished with exit code 1

有人知道怎么了吗?

确保您提供正确的spreadsheetID 错误表示找不到电子表格。

您可以使用电子表格sheets.values.get进行尝试来验证这一点。 如果发出同样的错误,则意味着您需要重新检查spreadsheetID ID。

这是一个电子表格 ID的样子:

https://docs.google.com/spreadsheets/d/1qpyC0XzvTcKT6EISywvqESX3A0MwQoFDE8p-Bll4hps/edit#gid=0

电子表格ID

1qpyC0XzvTcKT6EISywvqESX3A0MwQoFDE8p-Bll4hps

暂无
暂无

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

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