//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C

//Path of input excel file
StringPtr sampleGroupingUngroupingRowsAndColumns = dirPath->StringAppend(new String("sampleGroupingUngroupingRowsAndColumns.xlsx"));

//Path of output excel file
StringPtr outputGroupingUngroupingRowsAndColumns = outPath->StringAppend(new String("outputGroupingUngroupingRowsAndColumns.xlsx"));

//Read input excel file
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(sampleGroupingUngroupingRowsAndColumns);

//Accessing the first worksheet in the Excel file
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0);

//Grouping first seven rows and first four columns
worksheet->GetICells()->GroupRows(0, 6, true);
worksheet->GetICells()->GroupColumns(0, 3, true);

//Save the Excel file.
workbook->Save(outputGroupingUngroupingRowsAndColumns);