The Google SpreadsheetService seems a 'work in progress' with sometimes/suddenly slow answers, random error messages etc. As some people already suggest i'm using the Google Drive API where possible when working with the Spreadsheet API. But i couldn't find decent documentation about the Google Drive/Spreadsheet API mix.
With some debugging and trial/error i created an 'entrypoint' at the level of SpreadsheetEntry
:
String lSpreadsheetFileId = pSpreadsheetFile.getId();
String lSpreadsheetUrlString = String.format("https://spreadsheets.google.com/feeds/spreadsheets/%s", lSpreadsheetFileId);
URL lSpreadsheetUrl = new URL(lSpreadsheetUrlString);
SpreadsheetEntry lSpreadsheetEntry = mSpreadsheetService.getEntry(lSpreadsheetUrl, SpreadsheetEntry.class);
Now i can start with a query on the SpreadsheetService or with a Google Drive File. Both deliver a SpreadsheetEntry
. From this point the code is equal for both situations.
This works, but is is my own Google hacking solution which could break with an update on the interface. I saw some posts with more 'official' methods:
urlFactory.getWorksheetFeedUrl(file.getId(), "private", "full"); // (or any other feed url builder). file.getId()
What is the official 'by design' way to use Google Drive files with Google Spreadsheet?
Can i get some real code examples (more than; "just use the feed" etc.)?
Google Spreadsheet Service is already deprecated. Use Google Apps Script API instead on your implementation on integrating Google Drive and Spreadsheet. Using the Apps Script API, you can almost implement most of the Google Apps integration in your application.
If you really need a
SpreadsheetEntry
, you have to sift through theSpreadsheetFeed
and look for the key. You can implement a title query to reduce the number of spreadsheets to examine:There doesn't seem to be a query for the key. However, there is hardly a functionality that requires a SpreadsheetEntry and cannot be done with Drive API or lower level feeds (Worksheed, List, or CellFeed)