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.)?