Search code examples
python-2.7pygsheets

How can a worksheet be shared on team drive through pygsheet


I have worksheet with 2 sheets and Need to share it on team Drive. I read the documentation on pyghsheet ,In share pygsheet.share method we can pass group/user , But how can we share on a teamDrive.

gc= pygsheets.authorize(outh_nonlocal=True)
gc.enableTeamDriveSupport = True

gc.teamDriveId = "xxxxxxxxxxxxx"
print " aurhorization done"
sheet= gc.create("Price-"+oldDate)
sheet.add_worksheet("Sheet2",rows=1000,cols=15)
workSheet=sheet[0]
workSheet.set_dataframe(finalPrice,(1,1))
workSheet=sheet[1]
workSheet.set_dataframe(intermediate,(1,1))
sheet.share(??????)

How it can be achieved.


Solution

  • As you want to create a sheet on a teamDrive, just specify the id of a folder where you want the sheet to be created

    gc= pygsheets.authorize(outh_nonlocal=True)
    gc.enableTeamDriveSupport = True
    
    gc.teamDriveId = "xxxxxxxxxxxxx"
    print " aurhorization done"
    sheet= gc.create("Price-"+oldDate, parent_id="xxxxxxxx") # your folder id as parent
    sheet.add_worksheet("Sheet2",rows=1000,cols=15)
    workSheet=sheet[0]
    workSheet.set_dataframe(finalPrice,(1,1))
    workSheet=sheet[1]
    workSheet.set_dataframe(intermediate,(1,1))