问题
Can you customize / change the spreadsheet ID of a Google Sheet (ie. the ID string that shows up in the gsheet's URL)?
I ask this because when looking at the docs for the gsheet api's create() method and looking at the expected request body template, I see that one of the fields available is the spreadsheetId
. Does this mean that I can create()
a spreadsheet with a specific spreadsheetId
?
I find the docs for the API request bodies to be unclear about what certain fields are and when they are optional.
回答1:
Can you customize / change the spreadsheet ID of a Google Sheet
Answer:
Unfortunately, no this isn't possible.
More Information:
While the spreadsheets.create
method does imply that you can select a custom spreadsheet ID when creating a new Spreadsheet, you can see this on the documentation page for the spreadsheet REST Resource (emphasis my own):
Fields:
spreadsheetId
stringThe ID of the spreadsheet. This field is read-only.
As the spreadsheetId
field is read-only, if one provides an ID to the API on creation, then the field will be ignored and an ID will be generated all the same.
I know this is generally bad news, but I hope this is helpful to you!
References:
- Method: spreadsheets.create | Sheets API | Google Developers
- REST Resource: spreadsheets | Sheets API | Google Developers
来源:https://stackoverflow.com/questions/63243721/can-you-customize-change-the-spreadsheet-id-of-a-google-sheet