How to fetch the ID of a Google Spread Sheet via Google Apps Script?

后端 未结 3 1234
南方客
南方客 2020-12-29 13:38

I\'ve created one Google spread sheet and I want to find the ID of that spread sheet. I\'ve tried too much to search on Google but could not succeed.

Please show me

3条回答
  •  我在风中等你
    2020-12-29 14:09

    The ID (key) of the spreadsheet is in the URL (the part between key= and #gid=). You can retrieve it with GAS using something like:

    function getId() {
      Browser.msgBox('Spreadsheet key: ' + SpreadsheetApp.getActiveSpreadsheet().getId());
    }
    

    Note, often you will get a totally different string with each method, but they both should work the same.

提交回复
热议问题