我有一个工作的例子,我来到这里。 https://developers.google.com/google-apps/spreadsheets/我需要从用户的Google文档中下载一些文件。
import com.google.gdata.client.spreadsheet.*;
import com.google.gdata.data.spreadsheet.*;
import com.google.gdata.util.*;
import java.io.IOException;
import java.net.*;
import java.util.*;
public class MySpreadsheetIntegration {
public static void main(String[] args)
throws AuthenticationException, MalformedURLException, IOException, ServiceException {
SpreadsheetService service =
new SpreadsheetService("MySpreadsheetIntegration-v1");
// TODO: Authorize the service object for a specific user (see other sections)
// Define the URL to request. This should never change.
URL SPREADSHEET_FEED_URL = new URL(
"https://spreadsheets.google.com/feeds/spreadsheets/private/full");
// Make a request to the API and get all spreadsheets.
SpreadsheetFeed feed = service.getFeed(SPREADSHEET_FEED_URL, SpreadsheetFeed.class);
List<SpreadsheetEntry> spreadsheets = feed.getEntries();
// Iterate through all of the spreadsheets returned
for (SpreadsheetEntry spreadsheet : spreadsheets) {
// Print the title of this spreadsheet to the screen
System.out.println(spreadsheet.getTitle().getPlainText());
}
}
}
现在我需要下载一些电子表格。如何使用Google电子表格API进行操作?
答案 0 :(得分:1)
使用google drive api下载电子表格。您可以下载CSV,PDF等。
代码示例:如何使用drive api下载 - Getting a merged cell width on Google Spreadsheet API
要使用数据更新电子表格,请使用Spreadsheet-api。请参阅此google示例http://gdata-java-client.googlecode.com/svn-history/r51/trunk/java/sample/spreadsheet/cell/CellDemo.java
您还可以使用功能更强大的google-apps-script来更新电子表格(服务器端java脚本)。