3

我有一个公开的谷歌电子表格,表格中有一些数据。

我正在开发一个 Android 应用程序,我希望它读取这些表格,然后使用电子表格上的字段创建一个列表视图。

哪种方法是最好的方法?

4

2 回答 2

2

您可以使用 James Moore 的代码:http: //blog.restphone.com/2011/05/very-simple-google-spreadsheet-code.html

package com.banshee;

import java.io.IOException;
import java.net.URL;

import com.google.gdata.client.spreadsheet.SpreadsheetService;
import com.google.gdata.data.spreadsheet.CustomElementCollection;
import com.google.gdata.data.spreadsheet.ListEntry;
import com.google.gdata.data.spreadsheet.ListFeed;
import com.google.gdata.util.ServiceException;

public class SpreadsheetSucker {
  public static void main(String[] args) {
    SpreadsheetService service = new SpreadsheetService("com.banshee");
    try {
      // Notice that the url ends
      // with default/public/values.
      // That wasn't obvious (at least to me)
      // from the documentation.
      String urlString = "https://spreadsheets.google.com/feeds/list/0AsaDhyyXNaFSdDJ2VUxtVGVWN1Yza1loU1RPVVU3OFE/default/public/values";

      // turn the string into a URL
      URL url = new URL(urlString);

      // You could substitute a cell feed here in place of
      // the list feed
      ListFeed feed = service.getFeed(url, ListFeed.class);

      for (ListEntry entry : feed.getEntries()) {
        CustomElementCollection elements = entry.getCustomElements();
        String name = elements.getValue("name");
        System.out.println(name);
        String number = elements.getValue("Number");
        System.out.println(number);
      }
    } catch (IOException e) {
      e.printStackTrace();
    } catch (ServiceException e) {
      e.printStackTrace();
    }

  }
}
于 2013-08-05T06:12:27.177 回答
1

我开发了一个适用于 Android 的 SpreadSheet 客户端库。请尝试- http://code.google.com/p/google-spreadsheet-lib-android/

希望能帮助到你。

干杯,普拉桑塔

于 2010-12-18T14:59:44.003 回答