我有一個公開的Google表格,其中包含一些數據。如何從Google電子表格中爲Android應用讀取數據
我正在開發一個Android應用程序,我希望它讀取這些表格,然後使用電子表格中的字段進行列表視圖。
這將是最好的方式來做到這一點?
我有一個公開的Google表格,其中包含一些數據。如何從Google電子表格中爲Android應用讀取數據
我正在開發一個Android應用程序,我希望它讀取這些表格,然後使用電子表格中的字段進行列表視圖。
這將是最好的方式來做到這一點?
我開發了一個適用於Android的SpreadSheet的客戶端Lib。請嘗試 - http://code.google.com/p/google-spreadsheet-lib-android/
希望它有幫助。
乾杯, Prasanta
任何機會,你會願意釋放的源代碼?謝謝! – 2011-12-19 01:54:30
可以使用詹姆斯·穆爾的代碼: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();
}
}
}
試圖給看看以下解決方案: http://stackoverflow.com/questions/13838963/android-google-spreadsheet-api – 2012-12-14 09:03:41