Automatically resize columns in Google sheets

2019-04-09 15:23发布

问题:

I would like to have columns on google sheets automatically resize to fit my text, without me having to manually resize them after every entry. How do I do this?

回答1:

FYI -- For those who don't want to delve into scripting, but want a way to do it faster, you can auto-resize all the columns at once, manually: Hit Cmd+A (or Ctrl+A in Windows) to select everything, then move the mouse to the border between any two column headers -- as if you wanted to resize that one manually-- the cursor changes to an arrow... and double click. Found this trick here.



回答2:

Sounds like you want autoResizeColumn. Make an AppScript script and you can put

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

sheet.autoResizeColumn(COLUMN_NUMBER);

Which will resize the specified column based off its contents.

Run the function everytime you want to resize or put it in a trigger like onOpen().

However, it seems to have a maximum size that it will change to.



回答3:

FYI, I don't know an automatic method. But you can do it at once by:

  • selecting desired columns from their headers
  • right-click anywhere on the selected area
  • Select Resize columns...... part from the menu
  • Select Fit to Data
  • Click OK

And you are done.