Ara Toplamlar Oluşturma
Contents
[
Hide
]
Ara Toplamlar Oluşturma
Aşağıdaki örnek kod, Aspose.Cells kullanılarak ara toplamların nasıl oluşturulacağını gösterir.örnek excel dosyası ve B13:C19 hücre aralığında ara toplamlar oluşturur veçıktı excel dosyası. Aşağıdaki ekran görüntüsü, örnek ve çıktı excel dosyasının kodun yürütülmesinden sonra nasıl göründüğünü gösterir.
Basit kod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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<IWorkbook> wb = Factory::CreateIWorkbook(sampleCreatingSubtotals); | |
//Get first worksheet of the workbook | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Get the cells collection of the worksheet | |
intrusive_ptr<ICells> cells = ws->GetICells(); | |
//Create cell area covering the cell range B3:C19 | |
intrusive_ptr<ICellArea> ca = ICellArea::CreateICellArea(new String("B3"), new String("C19")); | |
//Create integer array of size 1 and set its first value to 1 | |
intrusive_ptr<Array1D<int>> totalList = new Array1D<int>(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); |