Reputation: 93
How can I automatically resize the columns in google spreadsheet to fit my text
I have a small bot that updates the spreadsheet every minute and I'm trying to find a way to resize the columns to fit the content but I can't figure out how to do this.
I tried using the autoResizeDimensions
request but with no success on making it work. Here's how my google spreadsheet looks like:
And here'w how I use the request
_requests = []
for i in SHEETS.values(): # {sheet name: sheet id}
dim = {
'autoResizeDimensions': {
'dimensions': {
'sheetId': i,
'dimension': 'COLUMNS',
'startIndex': 0,
'endIndex': 7
}
}
}
_requests.append(dim)
sh.batch_update({"requests": _requests})
The code above runs after all the data in the sheet has been updated but it doesn't seem to have any effect on doing it.
Is there something I'm doing wrong? Or maybe I'm missing something. Edit:
Ok the problem wasn't with the request, it was with the way I was doing it.
I had another request to update my data and because they we're separated batch updates this one took a while to finish. I should have payed more attention to my code before asking this question here.
Thanks.
Also if someone is still reading this, can someone give me a math formula to calculate the columns size based on the data in it? The auto resize from the Google API doesn't do a good job
Upvotes: 0
Views: 1271
Reputation: 93
Ok the problem wasn't with the request, it was with the way I was doing it.
I had another request to update my data and because they we're separated batch updates this one took a while to finish. I should have payed more attention to my code before asking this question here.
Thanks.
Upvotes: 0