A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/apps-script/reference/spreadsheet/group below:

Class Group | Apps Script

Class Group

Stay organized with collections Save and categorize content based on your preferences.

Group

Access and modify spreadsheet groups. Groups are an association between an interval of contiguous rows or columns that can be expanded or collapsed as a unit to hide/show the rows or columns. Each group has a control toggle on the row or column directly before or after the group (depending on settings) that can expand or collapse the group as a whole.

The depth of a group refers to the nested position of the group and how many larger groups contain the group. The collapsed state of a group refers to whether the group should remain collapsed or expanded after a parent group has been expanded. Additionally, at the time that a group is collapsed or expanded, the rows or columns within the group are hidden or set visible, though individual rows or columns can be hidden or set visible irrespective of the collapsed state.

Detailed documentation collapse()

Collapses this group.

const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
const range = sheet.getRange('2:3');
range.shiftRowGroupDepth(1);
const group = sheet.getRowGroup(2, 1);

// Collapses this group.
group.collapse();
Return

Group — This group, for chaining.

Scripts that use this method require authorization with one or more of the following scopes:

expand()

Expands this group.

const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
const range = sheet.getRange('2:3');
range.shiftRowGroupDepth(1);
const group = sheet.getRowGroup(2, 1);

// Expands this group.
group.expand();
Return

Group — This group, for chaining.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

getControlIndex()

Returns the control toggle index of this group. This is the index just before the range when the control toggle is shown before the group, or the index just after the range otherwise.

const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
sheet.setRowGroupControlAfter(true);
const range = sheet.getRange('2:3');
range.shiftRowGroupDepth(1);
const group = sheet.getRowGroup(2, 1);

// Returns 4
const controlIndex = group.getControlIndex();
Return

Integer — The control toggle index of this group.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

getDepth()

Returns the depth of this group.

const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
const range = sheet.getRange('2:3');
range.shiftRowGroupDepth(1);
const group = sheet.getRowGroup(2, 1);

// Returns 1 if the group is at depth 1.
const depth = group.getDepth();
Return

Integer — The depth of this group.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

getRange()

Returns the range over which this group exists.

const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
let range = sheet.getRange('2:3');
range.shiftRowGroupDepth(1);
const group = sheet.getRowGroup(1, 1);

// Returns the range 2:3 if the group is over rows 2:3
range = group.getRange();
Return

Range — The range over which the group exists.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

isCollapsed()

Returns true if this group is collapsed.

const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
const range = sheet.getRange('2:3');
range.shiftRowGroupDepth(1);
const group = sheet.getRowGroup(2, 1);

// Returns true if the group is collapsed.
const isCollapsed = group.isCollapsed();
Return

Booleantrue If this group is collapsed; returns false otherwise.

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

remove()

Removes this group from the sheet, reducing the group depth of the range by one. This may modify other groups. After calling this, the group object becomes invalid to use.

const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
let range = sheet.getRange('2:3');
range.shiftRowGroupDepth(1);
const group = sheet.getRowGroup(2, 1);

// Removes this group
range = group.remove();
Authorization

Scripts that use this method require authorization with one or more of the following scopes:

See also

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-12 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-12 UTC."],[[["Groups 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."],["Each 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."],["The `Group` class in Apps Script provides methods to programmatically manage groups, including collapsing, expanding, retrieving group properties, and removing groups."],["`Group` methods like `collapse()`, `expand()`, `getControlIndex()`, `getDepth()`, `getRange()`, `isCollapsed()`, and `remove()` offer control over group behavior and properties within your scripts."],["Utilizing these methods allows for dynamic manipulation of spreadsheet groups, enhancing the interactivity and organization of your spreadsheet data through automation."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4