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")