有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java下载谷歌电子表格使用谷歌电子表格api

我这里有一个有效的例子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());
}
}
}

现在我需要下载一些电子表格。如何使用谷歌电子表格api


共 (1) 个答案

  1. # 1 楼答案

    下载电子表格

    使用google drive api下载电子表格。您可以下载CSV、PDF等格式

    代码示例:如何使用驱动器api下载-Getting a merged cell width on Google Spreadsheet API

    使用电子表格api(gdata)更新

    要使用数据更新电子表格,请使用电子表格api。请参见此google示例http://gdata-java-client.googlecode.com/svn-history/r51/trunk/java/sample/spreadsheet/cell/CellDemo.java

    使用谷歌应用程序脚本更新

    您还可以使用功能更强大的GoogleApps脚本来更新电子表格(服务器端java脚本)