Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example implements working with data table totals settings and their types. After starting the example the following operations are executed:
Values of obtained data table totals settings.
A new object of data table totals is created, for which settings are determined, after which their values are displayed in the console.
New objects of totals types for data table rows and columns are created, for which new settings are determined.
The development environment console displays values of totals settings for data table rows and columns, and also the number of selected types of totals for rows and columns.
Executing the example requires to place the following code in the body of the executeExample method of the ViewController class (see the Data Analysis section):
// Get data table SPPLPivotTable pivotTable = m_gridPivotTable; // Get totals settings SPPLPivotTableTotalsSettings totalsSettings = pivotTable->totalsSettings(); // Display values of totals settings printf("%s %d \n","Whether parent data is taken into account:", totalsSettings->isIncludeParents()); printf("%s %d \n","Whether empty cells are treated as zero:", totalsSettings->isTreatEmptyAsZero()); printf("%s %d \n","Whether hierarchy is taken into account:", totalsSettings->isUseHierarchy()); printf("%s %d \n","Whether nesting levels are taken into account:", totalsSettings->isUseLevels()); // Create new totals settings SPPLPivotTableTotalsSettings newSettings = new PPLPivotTableTotalsSettings(); // Create a copy of totals settings SPPLPivotTableTotalsSettings copySettings = newSettings->copy()->qClass<PPLPivotTableTotalsSettings>(); // Set totals settings if(copySettings->isEmpty()){ copySettings->setIncludeParents(true); copySettings->setTreatEmptyAsZero(true); copySettings->setUseHierarchy(true); copySettings->setUseLevels(true); } printf("Values of totals settings copy: \n"); // Display values of totals settings printf("%s %d \n","whether parent data is taken into account:", copySettings->isIncludeParents()); printf("%s %d \n","Whether empty cells are treated as zero:", copySettings->isTreatEmptyAsZero()); printf("%s %d \n","Whether hierarchy is taken into account:", copySettings->isUseHierarchy()); printf("%s %d \n","Whether nesting levels are taken into account:", copySettings->isUseLevels()); // Get types of totals for data table rows and columns SPPLPivotTableTotalsTypes rowTypes = totalsSettings->rowTypes(); SPPLPivotTableTotalsTypes columnTypes = totalsSettings->columnTypes(); // If types of row totals are empty, create a new object and set totals states if(rowTypes->isEmpty()){ rowTypes = new PPLPivotTableTotalsTypes(); rowTypes->setCalculateMax(true); rowTypes->setCalculateAvg(false); rowTypes->setCalculateMin(false); rowTypes->setCalculateNotNullCount(false); rowTypes->setCalculateNullCount(false); rowTypes->setCalculateSum(false); } if(columnTypes->isEmpty()){ // Copy types of data table row totals columnTypes = rowTypes->copy()->qClass<PPLPivotTableTotalsTypes>(); // Clear types columnTypes->clear(); // Set calculation of totals by minimum columnTypes->setCalculateMin(true); } // Display settings of totals types for data table rows and columns printf("Whether row totals are used:\n"); printf("%s %d \n","Calculation of totals by average:", rowTypes->isCalculateAvg()); printf("%s %d \n","Calculation of totals by maximum:", rowTypes->isCalculateMax()); printf("%s %d \n","Calculation of totals by minimum:", rowTypes->isCalculateMin()); printf("%s %d \n","Calculation of number of non-empty cells:", rowTypes->isCalculateNotNullCount()); printf("%s %d \n","Calculation of number of empty cells:", rowTypes->isCalculateNullCount()); printf("%s %d \n","Calculation of totals by sum:", rowTypes->isCalculateSum()); printf("Whether column totals are used:\n"); printf("%s %d \n","Calculation of totals by average:", columnTypes->isCalculateAvg()); printf("%s %d \n","Calculation of totals by maximum:", columnTypes->isCalculateMax()); printf("%s %d \n","Calculation of totals by minimum:", columnTypes->isCalculateMin()); printf("%s %d \n","Calculation of number of non-empty cells:", columnTypes->isCalculateNotNullCount()); printf("%s %d \n","Calculation of number of empty cells:", columnTypes->isCalculateNullCount()); printf("%s %d \n","Calculation of totals by sum:", columnTypes->isCalculateSum()); // Display number of selected total types if(rowTypes->selectedTypes()!=NULL){ printf("%s %d\n", "Number of selected types of row totals:", rowTypes->selectedTypes()->count()); } if(rowTypes->selectedTypes()!=NULL){ printf("%s %d\n", "Number of selected types of column totals:", columnTypes->selectedTypes()->count()); }
As a result, the development environment console displays values of totals settings and their types.
Whether parent data is taken into account: 1
Whether empty cells are treated as zero: 0
Whether hierarchy is taken into account: 1
Whether nesting levels are taken into account: 1
Values of totals settings copy:
Whether parent data is taken into account: 1
Whether empty cells are treated as zero: 1
Whether hierarchy is taken into account: 1
Whether nesting levels are taken into account: 1
Whether row totals are used:
Calculation of totals by average: 0
Calculation of totals by maximum: 1
Calculation of totals by minimum: 0
Calculation of number of non-empty cells: 0
Calculation of number of empty cells: 0
Calculation of totals by sum: 0
Whether column totals are used:
Calculation of totals by average: 0
Calculation of totals by maximum: 0
Calculation of totals by minimum: 1
Calculation of number of non-empty cells: 0
Calculation of number of empty cells: 0
Calculation of totals by sum: 0
Number of selected types of row totals: 1
Number of selected types of column totals: 1
See also: