IRONSOFTWAREHOME
Group & Ungroup Excel Rows/Columns in Python
from ironxl import *

# Load existing spreadsheet
workbook = WorkBook.Load("sample.xlsx")
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")

# Save changes with grouped and ungrouped rows and columns
workbook.SaveAs("groupAndUngroup.xlsx")
pip install ironxl
Group & Ungroup Excel Rows/Columns in Python

Group & Ungroup Excel Rows/Columns in Python

Apply grouping and ungrouping of rows and columns in Excel using intuitive IronXL for Python APIs, without requiring Office Interop.

Group and Ungroup Rows

The GroupRows method groups rows by specifying their index positions. Multiple groupings can be applied using repeated calls to this method.

To ungroup rows, use the UngroupRows method. This method acts like a cutting tool - when applied to the middle of an existing row group, it splits that group into two. For example, ungrouping rows 2-4 within a group spanning 0-9 results in groups 0-1 and 5-9.

Group and Ungroup Columns

Columns can be grouped in the same way as rows. Use the GroupColumns method to group columns by their index positions or by specifying column names as strings. Multiple column groups can be created as needed.

To ungroup columns, use the UngroupColumns method, which also functions as a cutting tool. Applying it in the middle of a column group splits it in two. For instance, ungrouping columns C-D within a group A-F results in groups A-B and E-F.

All index positions use zero-based indexing. Grouping can only be applied as far as the cells contain values.

Learn to Group and Ungroup Excel Rows and Columns with IronXL for Python

Ready to Get Started?

Version:2026.10just 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 IronXL for Python
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get a Quote, No Obligation
Your details will always be kept confidential.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Trusted by Millions of Engineers Worldwide
Get your free 30-day Trial Key instantly.
No credit card or account creation required
Python Module Download for Excel
Install with pip

Version: 2026.10

  1. Download and install Python 3.7+.
  2. Install pip from pypi.org if it isn't installed already.
  3. Execute the above command in the terminal.
Python PDF Module
Download Module

Version: 2026.10

Manually install into your project

  1. Download the package
  2. Run this command from the terminal
    pip install IronXL-2026.10-py37-none-win_amd64.whi

Licenses from $999