使用 java api 在 google sheet 中使用 listFeed 获取特定列
fetching specific columns using listFeed in googlesheet using java api
我只想获取电子表格中基于 header 的特定列。
我尝试了以下代码
ListQuery query=new ListQuery(url);
query.setFields("FieldName");
但出现以下错误:
Exception in thread "main" com.google.gdata.util.InvalidEntryException: Bad Request
Fields query parameter is not supported
at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:602)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:564)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
at com.google.gdata.client.Service.getFeed(Service.java:1135)
at com.google.gdata.client.Service.getFeed(Service.java:1077)
at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:676)
at com.google.gdata.client.Service.query(Service.java:1237)
at com.google.gdata.client.Service.query(Service.java:1178)
有没有一种方法可以使用 ListQuery 或 url 只获取特定列而不是 listfeed,或者有其他方法
如果您使用 Visualization Query Language
,您可以 select 列
例如 select 大 sheet 的 B 和 C 列(第 2 和第 3)(来自 this tutorial):
https://docs.google.com/a/temet.ch/spreadsheets/d/1jwKyiVro8ZqPr5jRsyCN7igPJ76vOvtRy_xq3I8nKVI/gviz/tq?tqx=out:html&gid=0&tq=select%20B,C
查询 returns JSONP 如果你离开 tqx=out:html
参数,但你不会得到 ListEntries。
请注意,列名是 sheet 的原生 A、B、C...,它不使用第 1 行中的 headers 作为 ListFeed
ListFeed 示例
http://gdata-java-client.googlecode.com/svn/trunk/java/sample/spreadsheet/list/ListDemo.java
但我觉得 "CellFeed" 几乎在所有方面都更好。
如果您只想 "read" 数据,还有一些其他选项。
我只想获取电子表格中基于 header 的特定列。 我尝试了以下代码
ListQuery query=new ListQuery(url);
query.setFields("FieldName");
但出现以下错误:
Exception in thread "main" com.google.gdata.util.InvalidEntryException: Bad Request
Fields query parameter is not supported
at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:602)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:564)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
at com.google.gdata.client.Service.getFeed(Service.java:1135)
at com.google.gdata.client.Service.getFeed(Service.java:1077)
at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:676)
at com.google.gdata.client.Service.query(Service.java:1237)
at com.google.gdata.client.Service.query(Service.java:1178)
有没有一种方法可以使用 ListQuery 或 url 只获取特定列而不是 listfeed,或者有其他方法
如果您使用 Visualization Query Language
,您可以 select 列例如 select 大 sheet 的 B 和 C 列(第 2 和第 3)(来自 this tutorial): https://docs.google.com/a/temet.ch/spreadsheets/d/1jwKyiVro8ZqPr5jRsyCN7igPJ76vOvtRy_xq3I8nKVI/gviz/tq?tqx=out:html&gid=0&tq=select%20B,C
查询 returns JSONP 如果你离开 tqx=out:html
参数,但你不会得到 ListEntries。
请注意,列名是 sheet 的原生 A、B、C...,它不使用第 1 行中的 headers 作为 ListFeed
ListFeed 示例
http://gdata-java-client.googlecode.com/svn/trunk/java/sample/spreadsheet/list/ListDemo.java
但我觉得 "CellFeed" 几乎在所有方面都更好。
如果您只想 "read" 数据,还有一些其他选项。