IRONSOFTWAREHOME
Group & Ungroup Rows & Columns
using IronXL;

// Load existing spreadsheet
WorkBook workBook = WorkBook.Load("sample.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;

// Apply grouping to row 1-5
workSheet.GroupRows(0, 4);

// Ungroup row 3-5
workSheet.UngroupRows(2, 4);

// Apply grouping to column A-F
workSheet.GroupColumns(0, 5);

// Ungroup column C-D will cut the grouping at B
workSheet.UngroupColumn("C", "D");

workBook.SaveAs("groupAndUngroup.xlsx");
Imports IronXL

' Load existing spreadsheet
Dim workBook As WorkBook = WorkBook.Load("sample.xlsx")
Dim workSheet As WorkSheet = workBook.DefaultWorkSheet

' Apply grouping to row 1-5
workSheet.GroupRows(0, 4)

' Ungroup row 3-5
workSheet.UngroupRows(2, 4)

' Apply grouping to column A-F
workSheet.GroupColumns(0, 5)

' Ungroup column C-D will cut the grouping at B
workSheet.UngroupColumn("C", "D")

workBook.SaveAs("groupAndUngroup.xlsx")
NuGet Download
PM > Install-Package IronXL.Excel
Group & Ungroup Rows & Columns

Group & Ungroup Rows & Columns

Apply group and ungroup of rows & columns with intuitive APIs without using Office Interop with IronXL library.

Group & Ungroup Rows

The GroupRows method groups rows by taking index positions. You can apply multiple groupings using this method.

To ungroup rows, use the UngroupRows method. This method acts like a cutting tool. When applied to the middle of a row group, it splits the group into two. However, the new groups remain connected as a single logical group. For example, ungrouping rows 2-4 within a group spanning 0-9 will result in groups 0-1 and 5-9.

Group & Ungroup Columns

Columns can be grouped similarly to rows. Use the GroupColumns method to group columns by index or by specifying column names as strings. Create multiple column groups if needed.

Ungroup columns with the UngroupColumns method, which also acts as a cutting tool. Applying it at the center of a column group splits it into two. For instance, ungrouping columns C-D within a group A-F results in groups A-B and E-F.

Please note that all index positions mentioned above follow zero-based indexing. Grouping can only be applied as far as the cells contain values.

Learn to Group & Ungroup Excel Rows and Columns with IronXL
View on GitHub

Ready to Get Started?

Nuget Downloads 2,237,574Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required