A
A
andriy71122019-01-28 19:47:25
Python
andriy7112, 2019-01-28 19:47:25

How to create a new sheet and change its name in Google spreadsheet?

How to use python to create a new sheet and change its name in google spreadsheet?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Demidov, 2019-01-28
@ptitca_zu

Documentation

A
Alexander Ivanov, 2019-01-28
@oshliaer

Probably gspreadnot a bad solution, but with the advent of the Sheets API v4, things have become a little easier.

spreadsheetId=''
new_sheet_title=''

from googleapiclient.discovery import build
service = build('sheets', 'v4')

requests = []

requests.append({
    'addSheet': {
        'properties': {
            'title': new_sheet_title
        }
    }
})

body = {
    'requests': requests
}

response = service.spreadsheets().batchUpdate(
  spreadsheetId=spreadsheetId,
  body=body).execute()

You can run the code "here and now" at the link https://colab.research.google.com/drive/1_IdQAxqk7...

D
Dimonchik, 2019-01-28
@dimonchik2013

https://github.com/burnash/gspread

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question