Android - 谷歌电子表格 API

时间:2023-03-19
本文介绍了Android - 谷歌电子表格 API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道应该使用哪些库来开发管理 Google 电子表格的 Android 应用.我需要连接、复制、编辑、读取用户电子表格,但我今天不明白这是哪种方式.

I can't get which libs i should use for developing an Android app that menages Google spreadsheet. I need connecting, copying, editing, reading from a user spreadsheet but i can't understand today which is the way.

Google Drive Api : https://developers.google.com/drive/
Google Spreadsheet Api: https://developers.google.com/google-apps/spreadsheets/
Google APi java client: http://code.google.com/p/google-api-java-client/

哪个是正确的?

推荐答案

最后我用到的库是:

gdata-client-1.0.jar
gdata-client-meta-1.0.jar
gdata-core-1.0.jar
gdata-spreadsheet-3.0.jar
gdata-spreadsheet-meta-3.0.jar
google-api-client-1.12.0-beta.jar
google-api-client-android-1.12.0-beta.jar
google-http-client-1.12.0-beta.jar
google-http-client-android-1.12.0-beta.jar
google-oauth-client-1.12.0-beta.jar
gson-2.1.jar
guava-13.0.1.jar
jackson-core-asl-1.9.9.jar
jsr305-1.3.9.jar
protobuf-java-2.4.1.jar

正如 Eugenio 所建议的(谢谢!!!)我将电子表格 api 中的库与 java-client-api 混合",在身份验证后,我使用以下内容获取单元格

As suggested by Eugenio (thanks for that!!!) i "mixed" libraries from spreadsheet api with the java-client-api and after the authentication i used the following for getting the cells

SpreadsheetEntry spreadsheet = null;
URL metafeedUrl = new URL("https://spreadsheets.google.com/feeds/spreadsheets/private/full");

SpreadsheetFeed spreadsheetFeed = service.getFeed(metafeedUrl, SpreadsheetFeed.class);
List<SpreadsheetEntry> spreadsheets = spreadsheetFeed.getEntries();
for (SpreadsheetEntry entry : spreadsheets) {
   if (entry.getTitle().getPlainText().equals(spreadsheetTitle)) {
      spreadsheet = entry;
   }
}

if (spreadsheet == null) {
    throw new FileNotFoundException("Cannot find the required spreadsheet '" + spreadsheetTitle + "'");
}

WorksheetEntry worksheet = null;
WorksheetFeed worksheetFeed = service.getFeed(spreadsheet.getWorksheetFeedUrl(), WorksheetFeed.class);
List<WorksheetEntry> worksheets = worksheetFeed.getEntries();
    for (WorksheetEntry entry : worksheets) {
    if (entry.getTitle().getPlainText().equals(worksheetTitle)) {
         worksheet = entry;
    }
}

if (worksheet == null) {
    throw new FileNotFoundException("Cannot find the required worksheet '" + worksheetTitle + "'");
}

URL listFeedUrl = worksheet.getListFeedUrl();
ListFeed listFeed = service.getFeed(listFeedUrl, ListFeed.class);

目前我使用的是最差"的身份验证系统,我应该在 OAuth2 中打开它,但目前 ClientLogin 是以这种方式完成的:

For the moment i used the "worst" authentication system and i should turn this in the OAuth2 but for the moment the ClientLogin is done in this way:

SpreadsheetService service = new SpreadsheetService("v1");
service.setProtocolVersion(SpreadsheetService.Versions.V3);
service.setUserCredentials(email, password);

这篇关于Android - 谷歌电子表格 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:Google Drive SDK 异常 下一篇:在 Android 上获取所有文件夹 google drive api

相关文章

最新文章