Reputation: 4673
I have a working example that I got here. https://developers.google.com/google-apps/spreadsheets/ I need to download some files from user's google doc.
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());
}
}
}
Now I need to download some spreadsheets. How do I do it with google spreadsheet api?
Upvotes: 0
Views: 3913
Reputation: 3700
Use the google drive api to download spreadsheets. You can download as CSV, PDF etc.
Code sample: how to download with drive api - Getting a merged cell width on Google Spreadsheet API
To update the spreadsheet with data, use the Spreadsheet-api. See this google example http://gdata-java-client.googlecode.com/svn-history/r51/trunk/java/sample/spreadsheet/cell/CellDemo.java
You can also use the more powerful google-apps-script to update a spreadsheet (server side java script).
Upvotes: 1