Reputation: 980
I want to reorder a Sheet1 moving it from index 6 to index 0.
def rename_worksheet(spreadsheet_id,
sheet_id,
new_title,
credentials, index=0):
service = discovery.build('sheets', 'v4', credentials=credentials)
requests = {
"updateSheetProperties": {
"properties": {
"sheetId": sheet_id,
"title": new_title,
"index": index,
},
"fields": "title",
}
}
body = {
'requests': requests
}
service.spreadsheets().batchUpdate(spreadsheetId=spreadsheet_id, body=body).execute()
But the sheet remains on It's old position.
Upvotes: 1
Views: 100
Reputation: 201368
How about this modification?
In your request body, by "fields": "title"
, only the title is updated. In your case, please add index
to fields
as follows. By this, the title and index of the sheet are updated.
"fields": "title",
"fields": "title,index",
Upvotes: 1