Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to integrate Google Drive and Spreadsheet API, to work with spreadsheets in a particular Google Drive folder?

Both Google Drive API and Google Spreadsheet API (v 3.0) support methods for getting the [KEY] corresponding to the following URL:

https://docs.google.com/spreadsheet/ccc?key=[KEY]

I am using the File.getId() method for the Google Drive API, and the SpreadsheetEntry.getId or .getKey() methods for Google Spreadsheet API.

Google Drive API...

for (File file : mResult) {
    System.out.println(file.getTitle());
    System.out.println(file.getId());
}

Google SpreaSheet API...

SpreadsheetEntry spreadsheet = spreadsheets.get(0);
System.out.println(spreadsheet.getKey());

My trouble is that I cannot find any common key between the Drive and Spreadsheet APIs, yet both keys link to the same resource....they both retrieve the same spreadsheet when used to replace the [KEY] field in a browser.

I am trying to identify the spreadsheets that exist in a specific folder in Google Drive, and then use the Spreadsheet API to work with only those files. The SpreadSheet API seems to only be able to return all the files on a Google drive -- i see no way to limit results by folders. Hence why I must combine the two APIs.

Any thoughts?

like image 303
user1930140 Avatar asked Nov 03 '22 07:11

user1930140


1 Answers

To get a worksheet by google id by this URL

https://spreadsheets.google.com/feeds/worksheets/" + googleId + "/private/full"

"googleId" is from drive SDK. worksheet more like a spreadsheet file on drive.

like image 146
atu0830 Avatar answered Nov 16 '22 19:11

atu0830