Is there a way to manipulate row with in Google Sheets using gspread API for Pyton? Autofit will be great but manually change size is ok too.
If my understanding is correct, how about this sample script? Please think of this as just one of several answers.
In this sample script, I used "autoResizeDimensions" with batch_update()
of gspread. This uses spreadsheets.batchUpdate of Sheets API.
spreadsheetName = "###" # Please set Spreadsheet name.
sheetName = "###" # Please set sheet name.
ss = client.open(spreadsheetName)
sheetId = ss.worksheet(sheetName)._properties['sheetId']
body = {
"requests": [
{
"autoResizeDimensions": {
"dimensions": {
"sheetId": sheetId,
"dimension": "COLUMNS",
"startIndex": 0, # Please set the column index.
"endIndex": 2 # Please set the column index.
}
}
}
]
}
res = ss.batch_update(body)
startIndex
and endIndex
uses 0
and 2
, respectively. This means that the width of column "A" and "B" of sheetName
are automatically resized.ss = client.open(spreadsheetName)
to ss = client.open_by_key(spreadsheetId)
.If I misunderstood your question and this was not the direction you want, I apologize.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With