I have a Google Sheet that does dynamic grouping with a script. I am looking for a function that gets rid of all those [Groups](https://developers.google.com/apps-script/reference/spreadsheet/group) in the sheet again.

Similar to [`expandAllColumnGroups`](https://developers.google.com/apps-script/reference/spreadsheet/sheet#expandallcolumngroups), I would like to have a function called `removeAllColumnGroups` - but it seems there is no such function available.

My current approach is very slow and cumbersome. I did quite some research but could not even find a way to get all the `columnGroups` or at least the start-column-IDs in a sheet, so I iterate over every column and literally **try** to remove the group if there is one, as there is no way to tell if a group exits. Unfortunately for about 90 columns this takes ages (minutes, really)...

```
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sh = ss.getActiveSheet();

  //remove all column-groups
  var group = null;
  var maxCol = sh.getMaxColumns();
  for(var c = 1; c <= maxCol; c++) {
    try {
      group = sh.getColumnGroup(c, 1); // Try to get group
      group.remove(); // Remove the group
    } catch (e) {
      //Logger.log("No Group at ColIndex "+c);
    }
  }

```

Any ideas would be really appreciated. Thanks in advance!