问题
I am developing an Android App that has to retrieve data from a Google spreadsheet. I have found posts online that suggest that I use the Google drive API but I haven't found any example on how this can be done. Can someone please help me with an example on retrieving data from a Google spreadsheet using the Google Drive API? Thanks
回答1:
The Drive API will only allow you to download the spreadsheet file. If you want to retrieve cell data from within a spreadsheet you must use the older spreadsheet API. https://developers.google.com/google-apps/spreadsheets/
回答2:
This is what I figured out on how to retrieve data from a Google Spreadsheet, with thanks also going to pinoyyid for his post. First download the gdata library from http://code.google.com/p/gdata-java-client/downloads/list.
In order to integrate the library with your project, assuming you are using Eclipse in Windows, follow these steps:
1. Unzip the folder and copy the following jar files contained in the path:
gdata-src.java-1.47.1\gdata\java\lib and gdata-src.java-1.47.1\gdata\java\deps into the "libs" folder in your project directory:
gdata-client-1.0
gdata-client-meta-1.0
gdata-core-1.0
gdata-spreadsheet-3.0
gdata-spreadsheet-meta-3.0
guava-13.0.1
2. Once copied refresh the project in Eclipse by going to File --> Refresh. The files should now appear in libs
in the project tree.
3. Expand the libs
directory in the project tree and right click on the jars you want to include and select "add to build path".
4. Now follow the instructions at https://developers.google.com/google-apps/spreadsheets/.
Enjoy!
回答3:
While the gdata libs will work, I'm not sure I'd suggest using them for a new project. From http://code.google.com/p/gdata-java-client/ ...
Warning: We have stopped actively developing this client library, except critical bug fixes and support for some Google API's. However, this client library is not deprecated, and is considered the "stable" choice, unless you have a specific requirement that is only supported by the new client library below.
Android support
Since GData Java Client Library does not support Android, Android developers should instead use the new library Google API Client Library for Java. This new library provides other important features, such as OAuth 2.0 and Maven. Unfortunately, there is no provided service-specific libraries for Google Data APIs, and instead you need to write your own XML data model classes.
来源:https://stackoverflow.com/questions/13899539/retrieving-data-from-a-google-spreadsheet-in-an-android-app