I am trying to adjust the width of columns in a google sheet using GSpread, however I can't find any documentation on the subject all across the web. I have tried the actual project documents itself, and stack overflow.
I have looked through the documentation, and stack overflow, and nobody has asked a question like this before.
No code to show, as I haven't found any that may be relevant.
I am expecting the widen column 'A' in my sheet by around 100.
Thanks in advance for the help.
Cheers.
If my understanding is correct, how about this answer? In this modification, batch_update()
method is used.
Please set spreadsheetId
, sheetName
and the gridrange of range
.
spreadsheetId = "###"
sheetName = "Sheet1"
client = gspread.authorize(credentials)
ss = client.open_by_key(spreadsheetId)
sheetId = ss.worksheet(sheetName)._properties['sheetId']
body = {
"requests": [
{
"updateDimensionProperties": {
"range": {
"sheetId": sheetId,
"dimension": "COLUMNS",
"startIndex": 0,
"endIndex": 1
},
"properties": {
"pixelSize": 100
},
"fields": "pixelSize"
}
}
]
}
res = ss.batch_update(body)
startIndex: 0
and endIndex: 1
mean the column "A" because of dimension: "COLUMNS"
.dimension
is changed to ROWS
, the height of rows can be adjusted.If this was not useful for your situation, I apologize.