简体   繁体   English

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

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

I want to read the data from one of the public spreadsheet which is in pubhtml. 我想从pubhtml中的一个公共电子表格中读取数据。

How can I read above spreadsheet using google-api? 如何使用google-api阅读上述电子表格?

I already tried following steps but getting an error: 我已经尝试了以下步骤,但出现错误:

  1. I used google API doc with my spreadsheet id. 我将Google API文档与电子表格ID一起使用。

  2. Example: 例:

sheet-id- 2PACX-1vTe-
Cmpii1CsnufmSER7ObEuhBb4TGO29RRwcEAQjW8PYkHKQMfUvriPk2LPXyCm8HMKCIvNFXSqJkU
  1. Error: 错误:
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

Does anyone know what's wrong? 有人知道怎么了吗?

Make sure you're providing the correct spreadsheetID . 确保您提供正确的spreadsheetID Error implies there's no spreaddsheet found. 错误表示找不到电子表格。

You can use this spreadsheets.values.get Try-it to validate that. 您可以使用电子表格sheets.values.get进行尝试来验证这一点。 If it gives off the same error, it means you need to recheck your spreadsheetID . 如果发出同样的错误,则意味着您需要重新检查spreadsheetID ID。

This is what a spreadsheetID looks like: 这是一个电子表格 ID的样子:

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

spreadsheetID : 电子表格ID

1qpyC0XzvTcKT6EISywvqESX3A0MwQoFDE8p-Bll4hps 1qpyC0XzvTcKT6EISywvqESX3A0MwQoFDE8p-Bll4hps

暂无
暂无

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

相关问题 如何在未经身份验证的情况下使用Google Spreadsheet API Java库获取公开的Google电子表格数据 - How to get public Google Spreadsheet data using Google Spreadsheet API Java library without authentication 如何使用Java将Google文档(电子表格)设置为公开? - How to set a Google Doc (Spreadsheet) to public using Java? 使用Google Spreadsheet API在Google中的Google驱动器中创建电子表格 - Create Spreadsheet using Google Spreadsheet API in Google drive in Java 在Java中使用Google电子表格api创建Google电子表格 - creating a google spreadsheet using google spreadsheet api in java 如何使用Java Google Doc API共享电子表格 - How to share a spreadsheet using Java Google Doc API 如何使用Java和Google Spreadsheet API获取Google电子表格中单元格的内容 - How to get the contents of a cell in a google spreadsheet using java and Google Spreadsheet API 使用带有Java的API在Google电子表格中插入一行 - insert a row in to a google spreadsheet using the API with java 使用 Google API Java 客户端将数据库上传到 Google 电子表格 - Using Google API Java Client for Uploading Database to Google Spreadsheet Java Google Spreadsheet API:更新公共工作表'java.lang.UnsupportedOperationException:无法更新条目' - Java Google Spreadsheet API: Updating Public Worksheet 'java.lang.UnsupportedOperationException: Entry cannot be updated' 无法使用Google电子表格API访问电子表格 - Not able to access spreadsheet using google spreadsheet API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM