I am trying to copy / paste format from once column to another using gspread
. My sheet looks like this:
My result should look like this:
I tried:
But for some reason this does not copy the format and I am not sure where is my mistake.
GSHEETS_SCOPES = [
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/drive"
]
CLIENT_SECRET_GOOGLE_SHEETS = r"folder/file.json"
creds = ServiceAccountCredentials.from_json_keyfile_name(CLIENT_SECRET_GOOGLE_SHEETS, GSHEETS_SCOPES)
client = gspread.authorize(creds)
sheet = client.open("My Sheet")
body = {
"requests": [
{
"copyPaste": {
"source": {
"sheetId": sheet.id,
"startRowIndex": 1,
"endRowIndex": 30,
"startColumnIndex": 0,
"endColumnIndex": 1
},
"destination": {
"sheetId": sheet,
"startRowIndex": 1,
"endRowIndex": 30,
"startColumnIndex": 1,
"endColumnIndex": 2
},
"pasteType": "PASTE_FORMAT"
}
},
}
]
}
res = sheet.batch_update(body)