//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C //Path of input excel file StringPtr sampleCreatingSubtotals = dirPath->StringAppend(new String("sampleCreatingSubtotals.xlsx")); //Path of output excel file StringPtr outputCreatingSubtotals = outPath->StringAppend(new String("outputCreatingSubtotals.xlsx")); //Load sample excel file into a workbook object intrusive_ptr wb = Factory::CreateIWorkbook(sampleCreatingSubtotals); //Get first worksheet of the workbook intrusive_ptr ws = wb->GetIWorksheets()->GetObjectByIndex(0); //Get the cells collection of the worksheet intrusive_ptr cells = ws->GetICells(); //Create cell area covering the cell range B3:C19 intrusive_ptr ca = ICellArea::CreateICellArea(new String("B3"), new String("C19")); //Create integer array of size 1 and set its first value to 1 intrusive_ptr> totalList = new Array1D(1); totalList->SetValue(1, 0); //Apply subtotal, the consolidation function is Sum and it will be applied to second column cells->Subtotal(ca, 0, ConsolidationFunction_Sum, totalList); //Save the workbook in xlsx format wb->Save(outputCreatingSubtotals);