Frage

I am using the Google Drive SDK to create spreadsheets with this code:

File body = new File();
body.setTitle(title);
body.setMimeType("application/vnd.google-apps.spreadsheet");
body.setParents(Arrays.asList(new ParentReference().setId(currentParent)));
File file = driveHelper.getDrive().files().insert(body).execute();

Is there a way to get a specific spreadsheet created with the Drive SDK using Googles Spreadsheet API? I have many spreadsheets with the same name in different folders and when I am looping through all spreadsheets I don't want to compare the titles to get a specific spreadsheet.

War es hilfreich?

Lösung

Googles Spreadsheet API uses the spreadsheet key. This KEY is shown in the URL when you open a spreadsheet in the browser. To see it being used, there is a simple google demo CellDemo.java. http://gdata-java-client.googlecode.com/svn-history/r51/trunk/java/sample/spreadsheet/cell/CellDemo.java

I assume it is possible to get all keys from the drive api, because you can do this:

Drive driveService = new Drive.Builder(TRANSPORT, JSON_FACTORY, credential).build();
File file = driveService.files().get(this.spreadsheetKey).execute();
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top