0
votes

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

2
Welcome to stack questions starting with What is the best way to X are opinion based or to broad. We also don't supply code examples. If you are having a problem with your code we can help with that but by the looks of it your code is working. Please read stackoverflow.com/help/how-to-askDaImTo
Yes the code is working (now), but i'm looking for the actually 'designed' solutions by Google instead of my own hacking.Roland Beuker
Google Sheets is old gdata API Google would rather you use app scripts instead that is why you wont find any documentation or tutorials on how to use it.DaImTo

2 Answers

0
votes

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.

0
votes

If you really need a SpreadsheetEntry, you have to sift through the SpreadsheetFeed and look for the key. You can implement a title query to reduce the number of spreadsheets to examine:

    SpreadsheetQuery spreadsheetQuery 
    = new SpreadsheetQuery(urlFactory.getSpreadsheetsFeedUrl());
    spreadsheetQuery.setTitleQuery(spreadsheet);
    SpreadsheetFeed spreadsheetFeed = myService.query(spreadsheetQuery, SpreadsheetFeed.class);

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)