Select the cells and click Autosize (Ctrl+Shift+Z) in the Arrange menu or the Autosize button in the Format Panel (Ctrl+Shift+P):

autosize.png