【问题标题】:Google Sheets API row.getCustomElements().getTags() doesnt return any valuesGoogle Sheets API row.get CustomElements().getTags() 不返回任何值
【发布时间】:2017-03-08 14:10:20
【问题描述】:

我是 Android 世界的新手。我一直在参考很多教程来最终创建一个从 Google 表格访问数据的应用程序。我经历了很多线程,但每个人都建议使用与我在下面的代码中使用的格式相同的格式,但它没有返回任何值。

我的代码是..

private void getData() throws AuthenticationException, MalformedURLException, IOException、ServiceException、URISyntaxException{

    SpreadsheetService service = new SpreadsheetService("MySpreadsheetIntegration-v1");
    service.setProtocolVersion(SpreadsheetService.Versions.V3);

    URL SPREADSHEET_URL = new URL("https://spreadsheets.google.com/feeds/worksheets/14-oj9z-Z6_sGtrOdL9nqvV604yZxAUw33bAJY8tcYyw/public/basic");

    WorksheetFeed feed = service.getFeed(SPREADSHEET_URL,WorksheetFeed.class);
    List<WorksheetEntry> worksheets = feed.getEntries();
    WorksheetEntry worksheet = worksheets.get(0);
    Log.d("hello","Worksheet Title is "+worksheet.getTitle().getPlainText());
    Log.d("hello","Worksheet Row Count is "+Integer.toString(worksheet.getRowCount()));
    Log.d("hello","Worksheet Column Count is "+Integer.toString(worksheet.getColCount()));

    //URL listFeedURL = new URI(worksheet.getListFeedUrl().toString()).toURL();
    URL listFeedURL = worksheet.getListFeedUrl();
    Log.d("hello","URL is \n"+ listFeedURL.toString());

    ListFeed listFeed = service.getFeed(listFeedURL,ListFeed.class);

    for (ListEntry row: listFeed.getEntries()){
        Log.d("hello","Title "+row.getTitle().getPlainText());
        Log.d("hello","Size "+Integer.toString(row.getCustomElements().getTags().size()));
        for (String tag: row.getCustomElements().getTags()){
            //Log.d("hello",ProperValue(row.getCustomElements().getValue(tag)));
            Log.d("hello d",row.getCustomElements().getValue(tag).toString());
        }
    }

我的日志显示:

D/hello:工作表标题是联系人 D/hello:工作表行数为 1000 D/hello:工作表列数为 26 D/你好:网址是 https://spreadsheets.google.com/feeds/list/14-oj9z-Z6_sGtrOdL9nqvV604yZxAUw33bAJY8tcYyw/od6/public/basic D/你好:标题 100 D/你好:尺寸 0 D/你好:标题 101 D/你好:尺寸 0 D/你好:标题 190 D/你好:尺寸 0 D/你好:标题 192 D/你好:尺寸 0 D/你好:标题 145 D/你好:尺寸 0 D/你好:标题 103 D/你好:尺寸 0 D/你好:标题 923 D/你好:尺寸 0 D/你好:标题 34 D/你好:尺寸 0 D/你好:标题 23 D/你好:尺寸 0

虽然获取的 listfeed url 也绝对正确,但我不确定缺少什么。

我们将不胜感激。

【问题讨论】:

    标签: google-sheets


    【解决方案1】:

    很抱歉发布这样一个不成熟的问题。我弄清楚了这个问题。 这是因为我在 URL 的末尾使用了“/basic”。应该是“/full”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-16
      • 2018-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多