Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example implements working with data table. After starting the example the following operations are executed:
Table update is enabled, and data table row and column selection is started.
The development environment console displays values of data table row and column number, and also data from specified cell.
Number of settings of calculated table series is determined.
Table rows and columns are selected, after which information about selected rows and columns is displayed.
Row and column with specified indexes are deselected in turns, all rows and columns are deselected in turns.
After each deselecting the console displays information about selected data table rows and columns.
The data table copy is created and set up, in which all table elements are deselected if there are selected elements.
Data table row an column selection is ended, table update is disabled.
Data table object is deleted.
Executing the example requires to place the following code instead of the executeExample method of the ViewController class (see the Data Analysis section):
-(void)executeExample { // Get table of pivot object for building data tables SPPLPivotTable pivotTable = m_gridPivotTable; // Enable table update pivotTable->unlock(); // Start selecting table rows and columns pivotTable->beginChangingSelection(); // Display the number of table rows and columns printf("Number of table columns: %d\n", pivotTable->columnCount()); printf("Number of table rows: %d\n", pivotTable->rowCount()); // Display information about calculated table series printSettingsInfo(pivotTable); // Get and display cell data NSNumber *data = (NSNumber *)pivotTable->getData(3, 3)->nsObject(); NSLog(@"%@: %f", @"Cell data value", [data doubleValue]); // Select data table rows and columns for(int i = 1; i<=5; i++) { pivotTable->selectColumn(i); pivotTable->selectRow(i); } // Display information about selected row and columns printf("Number of selected rows: %d; columns: %d\n", pivotTable->selectedColumnIndices()->count(), pivotTable->selectedRowIndices()->count()); // Deselect rows and column with specified indexes pivotTable->deselectColumn(3); pivotTable->deselectRow(3); printf("Deselecting row and column\n"); // Display information about selected rows and columns printf("Number of selected rows: %d; columns: %d\n", pivotTable->selectedColumnIndices()->count(), pivotTable->selectedRowIndices()->count()); // Deselect all columns pivotTable->deselectAllColumns(); printf("Deselecting all columns\n"); // Display information about selected rows and columns printf("Number of selected rows: %d; columns: %d\n", pivotTable->selectedColumnIndices()->count(), pivotTable->selectedRowIndices()->count()); // Deselect all rows pivotTable->deselectAllRows(); printf("Deselecting all rows\n"); // Display information about selected rows and columns printf("Number of selected rows: %d; columns: %d\n", pivotTable->selectedColumnIndices()->count(), pivotTable->selectedRowIndices()->count()); // Create a new data table object SPPLPivotTable newPivotTable = PPLPivotTable::pivotTable(pivotTable->relatedPivot()); // Load table parameters SNID plist = pivotTable->generatePlist(); // Set up new table based on parameters newPivotTable->setupFromPlist(plist); // Deselect all rows and columns if(newPivotTable->selectedColumnIndices()->count() != 0 || newPivotTable->selectedRowIndices()->count() != 0) { newPivotTable->deselectAll(); } // End selecting of table rows and columns pivotTable->endChangingSelection(); // Disable table update pivotTable->lock(); // Delete table object pivotTable->~PPLPivotTable(); } // Displays information about calculated table series void printSettingsInfo(SPPLPivotTable pivotTable) { // Get calculated series settings SPPLPivotTableCalculatorSettings calculatorSettings = pivotTable->calculatorSettings(); printf("Number of calculated series settings: %d\n", calculatorSettings->settingsCount()); }
After executing the example the development environment console displays information about data table:
Number of table columns: 11
Number of table rows: 172
Number of calculated series settings: 0
Cell data value: 1880.266107
Number of selected rows: 5; columns: 5
Deselecting of row and column
Number of selected rows: 4; columns: 4
Deselecting of all columns
Number of selected rows: 0; columns: 4
Deselecting of all rows
Number of selected rows: 0; columns: 0
See also: