Mit Sammlungen den Überblick behalten Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Gruppe
Auf Tabellengruppen zugreifen und sie ändern Gruppen sind eine Verknüpfung zwischen einem Intervall zusammenhängender Zeilen oder Spalten, die als Einheit maximiert oder minimiert werden können, um die Zeilen oder Spalten ein- oder auszublenden. Jede Gruppe hat in der Zeile oder Spalte direkt vor oder nach der Gruppe (je nach Einstellungen) einen Schalter, mit dem die Gruppe als Ganzes maximiert oder minimiert werden kann.
Die Tiefe einer Gruppe bezieht sich auf die verschachtelte Position der Gruppe und darauf, wie viele größere Gruppen die Gruppe enthalten. Der minimierte Status einer Gruppe gibt an, ob die Gruppe minimiert oder maximiert bleiben soll, nachdem eine übergeordnete Gruppe maximiert wurde. Wenn eine Gruppe minimiert oder maximiert wird, werden die Zeilen oder Spalten in der Gruppe ausgeblendet oder sichtbar gemacht. Einzelne Zeilen oder Spalten können jedoch unabhängig vom minimierten Status ausgeblendet oder sichtbar gemacht werden.
Entfernt diese Gruppe aus dem Tabellenblatt und verringert die Gruppierungstiefe von range um eins.
Detaillierte Dokumentation
collapse()
Diese Gruppe wird minimiert.
constsheet=SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];constrange=sheet.getRange('2:3');range.shiftRowGroupDepth(1);constgroup=sheet.getRowGroup(2,1);// Collapses this group.group.collapse();
constsheet=SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];constrange=sheet.getRange('2:3');range.shiftRowGroupDepth(1);constgroup=sheet.getRowGroup(2,1);// Expands this group.group.expand();
Gibt den Index des Kontroll-Toggles dieser Gruppe zurück. Dies ist der Index direkt vor dem Bereich, wenn das Steuerelement vor der Gruppe angezeigt wird, oder der Index direkt nach dem Bereich, wenn das Steuerelement nach der Gruppe angezeigt wird.
constsheet=SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];constrange=sheet.getRange('2:3');range.shiftRowGroupDepth(1);constgroup=sheet.getRowGroup(2,1);// Returns 1 if the group is at depth 1.constdepth=group.getDepth();
Rückflug
Integer: Die Tiefe dieser Gruppe.
Autorisierung
Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:
Gibt den Bereich zurück, in dem diese Gruppe vorhanden ist.
constsheet=SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];letrange=sheet.getRange('2:3');range.shiftRowGroupDepth(1);constgroup=sheet.getRowGroup(1,1);// Returns the range 2:3 if the group is over rows 2:3range=group.getRange();
Rückflug
Range: Der Bereich, in dem die Gruppe vorhanden ist.
Autorisierung
Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:
Gibt true zurück, wenn diese Gruppe minimiert ist.
constsheet=SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];constrange=sheet.getRange('2:3');range.shiftRowGroupDepth(1);constgroup=sheet.getRowGroup(2,1);// Returns true if the group is collapsed.constisCollapsed=group.isCollapsed();
Rückflug
Boolean – true: Gibt false zurück, wenn diese Gruppe minimiert ist, andernfalls false.
Autorisierung
Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:
Entfernt diese Gruppe aus dem Tabellenblatt und verringert die Gruppierungstiefe von range um eins. Dadurch können sich andere Gruppen ändern. Nach dem Aufrufen dieser Funktion ist das Gruppenobjekt ungültig.
constsheet=SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];letrange=sheet.getRange('2:3');range.shiftRowGroupDepth(1);constgroup=sheet.getRowGroup(2,1);// Removes this grouprange=group.remove();
Autorisierung
Scripts, die diese Methode verwenden, benötigen eine Autorisierung für mindestens einen der folgenden Zugriffsbereiche:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-13 (UTC)."],[[["\u003cp\u003eGroups in Google Sheets allow you to associate contiguous rows or columns, enabling them to be expanded or collapsed as a single unit to control visibility.\u003c/p\u003e\n"],["\u003cp\u003eEach group has a control toggle located before or after the group, which dictates whether the group is expanded or collapsed, affecting the visibility of its rows or columns.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eGroup\u003c/code\u003e class in Apps Script provides methods to programmatically manage groups, including collapsing, expanding, retrieving group properties, and removing groups.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eGroup\u003c/code\u003e methods like \u003ccode\u003ecollapse()\u003c/code\u003e, \u003ccode\u003eexpand()\u003c/code\u003e, \u003ccode\u003egetControlIndex()\u003c/code\u003e, \u003ccode\u003egetDepth()\u003c/code\u003e, \u003ccode\u003egetRange()\u003c/code\u003e, \u003ccode\u003eisCollapsed()\u003c/code\u003e, and \u003ccode\u003eremove()\u003c/code\u003e offer control over group behavior and properties within your scripts.\u003c/p\u003e\n"],["\u003cp\u003eUtilizing these methods allows for dynamic manipulation of spreadsheet groups, enhancing the interactivity and organization of your spreadsheet data through automation.\u003c/p\u003e\n"]]],[],null,["Group\n\nAccess and modify spreadsheet groups. Groups are an association between an interval of contiguous\nrows or columns that can be expanded or collapsed as a unit to hide/show the rows or columns.\nEach group has a *control toggle* on the row or column directly before or after the group\n(depending on settings) that can expand or collapse the group as a whole.\n\nThe *depth* of a group refers to the nested position of the group and how many larger\ngroups contain the group. The *collapsed state* of a group refers to whether the group\nshould remain collapsed or expanded after a parent group has been expanded. Additionally, at the\ntime that a group is collapsed or expanded, the rows or columns within the group are hidden or\nset visible, though individual rows or columns can be hidden or set visible irrespective of the\ncollapsed state. \n\nMethods\n\n| Method | Return type | Brief description |\n|-----------------------------------------|---------------------------------------------------|-------------------------------------------------------------------------------------------------|\n| [collapse()](#collapse()) | [Group](#) | Collapses this group. |\n| [expand()](#expand()) | [Group](#) | Expands this group. |\n| [getControlIndex()](#getControlIndex()) | `Integer` | Returns the control toggle index of this group. |\n| [getDepth()](#getDepth()) | `Integer` | Returns the depth of this group. |\n| [getRange()](#getRange()) | [Range](/apps-script/reference/spreadsheet/range) | Returns the range over which this group exists. |\n| [isCollapsed()](#isCollapsed()) | `Boolean` | Returns `true` if this group is collapsed. |\n| [remove()](#remove()) | `void` | Removes this group from the sheet, reducing the group depth of the [range](#getRange()) by one. |\n\nDetailed documentation \n\n`collapse()` \nCollapses this group.\n\n```javascript\nconst sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];\nconst range = sheet.getRange('2:3');\nrange.shiftRowGroupDepth(1);\nconst group = sheet.getRowGroup(2, 1);\n\n// Collapses this group.\ngroup.collapse();\n```\n\nReturn\n\n\n[Group](#) --- this group, for chaining\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n`expand()` \nExpands this group.\n\n```javascript\nconst sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];\nconst range = sheet.getRange('2:3');\nrange.shiftRowGroupDepth(1);\nconst group = sheet.getRowGroup(2, 1);\n\n// Expands this group.\ngroup.expand();\n```\n\nReturn\n\n\n[Group](#) --- this group, for chaining\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n`get``Control``Index()` \nReturns the control toggle index of this group. This is the index just before the range when\nthe control toggle is shown before the group, or the index just after the range otherwise.\n\n```javascript\nconst sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];\nsheet.setRowGroupControlAfter(true);\nconst range = sheet.getRange('2:3');\nrange.shiftRowGroupDepth(1);\nconst group = sheet.getRowGroup(2, 1);\n\n// Returns 4\nconst controlIndex = group.getControlIndex();\n```\n\nReturn\n\n\n`Integer` --- the control toggle index of this group\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n`get``Depth()` \nReturns the depth of this group.\n\n```javascript\nconst sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];\nconst range = sheet.getRange('2:3');\nrange.shiftRowGroupDepth(1);\nconst group = sheet.getRowGroup(2, 1);\n\n// Returns 1 if the group is at depth 1.\nconst depth = group.getDepth();\n```\n\nReturn\n\n\n`Integer` --- the depth of this group\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n`get``Range()` \nReturns the range over which this group exists.\n\n```javascript\nconst sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];\nlet range = sheet.getRange('2:3');\nrange.shiftRowGroupDepth(1);\nconst group = sheet.getRowGroup(1, 1);\n\n// Returns the range 2:3 if the group is over rows 2:3\nrange = group.getRange();\n```\n\nReturn\n\n\n[Range](/apps-script/reference/spreadsheet/range) --- the range over which the group exists\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n`is``Collapsed()` \nReturns `true` if this group is collapsed.\n\n```javascript\nconst sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];\nconst range = sheet.getRange('2:3');\nrange.shiftRowGroupDepth(1);\nconst group = sheet.getRowGroup(2, 1);\n\n// Returns true if the group is collapsed.\nconst isCollapsed = group.isCollapsed();\n```\n\nReturn\n\n\n`Boolean` --- `true` if this group is collapsed; returns `false` otherwise\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n`remove()` \nRemoves this group from the sheet, reducing the group depth of the [range](#getRange()) by\none. This may modify other groups. After calling this, the group object becomes invalid to use.\n\n```javascript\nconst sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];\nlet range = sheet.getRange('2:3');\nrange.shiftRowGroupDepth(1);\nconst group = sheet.getRowGroup(2, 1);\n\n// Removes this group\nrange = group.remove();\n```\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\nSee also\n\n- [Range.shiftRowGroupDepth(delta)](/apps-script/reference/spreadsheet/range#shiftRowGroupDepth(Integer))\n- [Range.shiftColumnGroupDepth(delta)](/apps-script/reference/spreadsheet/range#shiftColumnGroupDepth(Integer))"]]