Search code examples
google-sheets-apigspread

Use gspread and Google sheets API to copy a sheet to multiple workbooks


I have a google sheet file called "template". It has 2 worksheets. I have 100 other files called "Instance01", "Instance02", etc. which have 2 worksheets with the same name as the ones in "template".

I have created a new worksheet in "template", called "sheet3". I want to copy it to each of the 100 "Instance" documents, keeping the name "sheet3" in each Instance.

Can I achieve that with gspread? And how? If not, is there another way to do it programatically (or within reasonable time and effort)?


Solution

  • As the method for copying the sheets, there is the method of "spreadsheets.sheets.copyTo" in Sheets API.

    You can see a sample script at this thread. I thought that because the object of credentials can be used for both gspread and googleapiclient, it might help to implement this.

    Reference: