Repository navigation
Grouping and Ungrouping Rows and Columns
Mats Alm edited this page Nov 10, 2026
·
8 revisions
This page has moved. The current version of this page is at https://epplussoftware.com/docs/worksheet-and-ranges/rows-and-columns/grouping-and-ungrouping-rows-and-columns/. The EPPlus documentation is no longer updated in this wiki; please use the EPPlus guides and update your bookmarks.
EPPlus can group rows and columns and add buttons to expand or collapse the groups.
Grouping of rows and columns is set by the OutlineLevel property.
EPPlus 6.1 provides several new methods to group and expand and collapse rows and columns.
| Member | Description |
|---|---|
OutlineLevel |
A property indicating the level of grouping for the row or column. |
Collapsed |
A property indicating that the row/column's children are collapsed. Setting this property will not hide the children. Use the CollapseChildren() or SetVisibleOutlineLevel() methods to collapse and hide columns/rows. |
Group() |
Groups rows or columns together. Adds one to OutlineLevel property from 1-8. |
Ungroup() |
Ungroups rows or columns. Subtracts one from OutlineLevel property. |
CollapseChildren(bool) |
Collapses and hides the children of the row/columns. If the first parameter is true, all children will be collapsed and hidden; otherwise, only the children on the level below will be collapsed. |
ExpandChildren(bool) |
Expands and shows the children of the row/columns. If the first parameter is true, all children will be expanded; otherwise, only the children on the level directly below will be expanded. |
SetVisibleOutlineLevel(int) |
Sets the visible level for a range of rows/columns. |
SetVisibleOutlineLevel(int,bool) |
Sets the visible level for a range of rows/columns. The second parameter sets if rows/columns lower than the visible level should be collapsed or left as is. |
The outline can also be set to be on top or below a group of rows or to the left or right of a group of columns.
This is set by the following properties on the ExcelWorksheet:
| Member | Description |
|---|---|
OutLineSummaryBelow |
If true, the expand/collapse buttons are below the row group; otherwise, on top. |
OutLineSummaryRight |
If true, the expand/collapse buttons are to the right of the column group; otherwise, to the left. |
worksheet.OutLineSummaryBelow = false;
worksheet.Rows[1, 15].Group();
worksheet.Rows[2, 15].Group();
worksheet.Rows[4, 15].Group();
worksheet.Rows[11, 12].Group();
worksheet.Rows[14, 15].Group();
worksheet.Cells["A3"].EntireRow.CollapseChildren(true); // Collapses the children rows of row 3. True means sub-levels are also collapsed.
- Group/Ungroup is used in our Sample 3.4 (C#) and Sample 3.4 (VB)
EPPlus Software AB - https://epplussoftware.com
- What is new in EPPlus 5+
- Breaking Changes in EPPlus 5
- Breaking Changes in EPPlus 6
- Breaking Changes in EPPlus 7
- Breaking Changes in EPPlus 8
- Addressing a worksheet
- Dimension/Used range
- Copying ranges/sheets
- Insert/Delete
- Filling ranges
- Sorting ranges
- Taking and skipping columns/rows
- Data validation
- Comments
- Freeze and Split Panes
- Header and Footer
- Hyperlinks
- Autofit columns
- Grouping and Ungrouping Rows and Columns
- Formatting and styling
- The ExcelRange.Text property
- Conditional formatting
- Using Themes
- Working with custom named table- or slicer- styles
-
Formula Calculation
- Security considerations
- Circular references
- Referencing tables in formulas
- Supported Functions
- Dynamic array formulas
- Legacy array formulas
- Lambda functions
- Regression analysis functions
- Custom functions for calculations
- Function prefixes
- Precision as Displayed
- Cancelling a calculation
- Trim reference operator
- Working with filters
- Working with slicers
- Working with External Workbooks