Ramel Henderson
https://developers.google.com/apps-script/guides/rest/api#parameter_and_return_types
Cuando se usa Google Execution Api para Java, la identificación de la hoja de cálculo no es muy fácil de entender. Aquí está el fragmento de código:
// Initialize parameters for that function.
String sheetId = "<ENTER_ID_OF_SPREADSHEET_TO_EXAMINE_HERE>";
List<Object> params = new ArrayList<Object>();
params.add(sheetId);
Cualquier idea sobre cómo localizar esto. Ejecuto la api de Sheets para devolver la identificación de una hoja de cálculo, pero devuelve un enlace, y cuando uso el https://hojas de cálculo.google.com/feeds/hojas de cálculo/CADENA o simplemente el CADENA en sí mismo todavía obtengo: “código”: 404, “errores”: [ {
“domain” : “global”,
“message” : “Requested entity was not found.”,
“reason” : “notFound”
Found this deep inside the Apps Script API reference.
A spreadsheet ID can be extracted from its URL. For example, the spreadsheet ID in the URL https://docs.google.com/spreadsheets/d/abc1234567/edit#gid=0 is “abc1234567”.
-
NVM, found right at top of docs: developers.google.com/sheets/api/guides/concepts
– lampShadesDrifterSep 9, 2021 at 4:37
https://developers.google.com/sheets/api/guides/concepts
states that:
Every API method requires a spreadsheetId parameter which is used to identify which spreadsheet is to be accessed or altered. This ID is the value between the “/d/” and the “/edit” in the URL of your spreadsheet. For example, consider the following URL that references a Google Sheets spreadsheet:
https://docs.google.com/spreadsheets/d/1qpyC0XzvTcKT6EISywvqESX3A0MwQoFDE8p-Bll4hps/edit#gid=0
The ID of this spreadsheet is 1qpyC0XzvTcKT6EISywvqESX3A0MwQoFDE8p-Bll4hps.
So I just pulled up my spreadsheet and looked at the URL to find my ID.
Hope this helps!
-
So uh… how do you find this ID just using code? It’s pretty useless for automation if you have to manually open each spreadsheet and copy/paste an ID from the URL…
– MichaelApr 3, 2022 at 15:46
-
@Michael did you make any progress? I’m having the same problem. I can retrieve an id for a sheet using
currentSheet.getSheetId();
but it is a simple integer (0 for a one sheet App) but can’t find anything equivalent to get the id of the SpreadsheetApp.– Dave PritloveAug 25, 2022 at 13:08
-
Don’t know if it helps, but in my case I was creating a sheet, so the BatchUpdateSpreadsheetRequest returns a BatchUpdateSpreadsheetResponse object, in the properties was the sheetId. execute.getReplies().get(0).getAddSheet().getProperties().getSheetId()
– CeePlusPlusDec 5, 2022 at 18:01
I just created a hyperlink to the sheets and then copied that hyperlink to a text file and the link line shows the GID.
Then I created a pull down list in A52 and then made =IF() logic to go to the GIDs to go to those sheets.
=IF(A52=”47QTCK18D0001″,HYPERLINK(“#gid=0″,”47QTCK18D0001″),IF(A52=”47QTCK18D0002”,HYPERLINK(“#gid=1049871492″,”47QTCK18D0002”) ….