2014-01-15 80 views
1

我使用的是谷歌硬碟SDK與此代碼創建電子表格創建的電子表格:獲取與硬碟SDK

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(); 

有沒有辦法讓使用谷歌電子表格API驅動器SDK創建一個特定的電子表格? 我有很多電子表格在不同的文件夾中有相同的名稱,當我遍歷所有 電子表格時,我不想比較標題以獲得特定的電子表格。

回答

0

谷歌電子表格API使用電子表格鍵。當您在瀏覽器中打開電子表格時,該鍵顯示在URL中。看到它被使用,有一個簡單的谷歌演示CellDemo.java。 http://gdata-java-client.googlecode.com/svn-history/r51/trunk/java/sample/spreadsheet/cell/CellDemo.java

我想這是可以從驅動器的API獲得所有鑰匙,因爲你可以這樣做:

Drive driveService = new Drive.Builder(TRANSPORT, JSON_FACTORY, credential).build(); 
File file = driveService.files().get(this.spreadsheetKey).execute();