//one column
sheet.getRange("G:G").getFormat().autofitColumns();
//all columns in sheet
range.getFormat().autofitColumns();