Working with Regular Report

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example describes some methods of working with regular report. After starting the example the following operations are executed:

Source Code

Executing the example requires to place the following code instead of the executeExample method of the ViewController class (see the Displaying of Regular Report section):

-(void)executeExample {
    // Get regular report
    SPPLReport report;
    if (m_proceduralReport->qClass<PPLProceduralReport>()) {
        report = m_proceduralReport->qClass<PPLProceduralReport>();
        // Get copy of regular report
        SPPLProceduralReport copy = report->copy()->qClass<PPLProceduralReport>();
        // Create a new regular report based on source report description in repository
        SPPLProceduralReport createdReport = PPLProceduralReport::proceduralReport(report->descriptor());
        printf("Key of regular report  worksheet: %d\n",copy->activeSheetKey());
        // Display information about new regular report resources
        [self printReportResources: createdReport->resources()];
        // Display information about available regular report worksheets
        [self printWorksheetsInfo: copy->worksheets()];
    }
    if (m_proceduralReport->qClass<PPLProceduralReport2>()) {
        report = m_proceduralReport->qClass<PPLProceduralReport2>();
        // Get regular report copy
        SPPLProceduralReport2 copy = report->copy()->qClass<PPLProceduralReport2>();
        // Create a new regular report based on source report description in repository
        SPPLProceduralReport2 createdReport = PPLProceduralReport2::proceduralReport(report->descriptor());
        printf("Key of regular report worksheet: %d\n",copy->activeSheetKey());
        // Display information about available regular report worksheets
        [self printWorksheetsInfo: copy->worksheets()];
    }
}

-(void)printReportResources: (SPPLReportResources) resources {
    printf("First resource identifier in new regular report: %s\n", resources->items()->objectAtIndex<PPLReportResource>(0)->id()->UTF8String());
}

-(void)printWorksheetsInfo: (SPPLProceduralReportWorksheets) worksheets {
    // Get data for list of worksheet container settings
    SNArray plist = worksheets->generatePlist()->qClass<NArray>();
    // Create a new worksheet container by means of settings list
    SPPLProceduralReportWorksheets createdWorksheets = new PPLProceduralReportWorksheets(plist);
    printf("Number of elements in new worksheet container: %d\n", createdWorksheets->items()->count());
    // Get array of available regular report worksheets
    SNArray worksheetItems = worksheets->items();
    // Get first worksheet from array
    SPPLProceduralReportWorksheet worksheet = worksheetItems->objectAtIndex<PPLProceduralReportWorksheet>(0);
    // Get data from list of first worksheet settings
    SNMutableDictionary plist2 = worksheet->generatePlist()->qClass<NMutableDictionary>();
    // Create a new worksheet by means of settings list
    SPPLProceduralReportWorksheet createdWorksheet = PPLProceduralReportWorksheet::worksheet(plist2);
    printf("First worksheet name: %s\n",worksheet->name()->UTF8String());
    printf("First worksheet key: %d\n",worksheet->key());
    printf("Whether new worksheet is visible: ");
    printf(createdWorksheet->isVisible()? "visible\n":"not visible\n");
}

After executing the example the development environment console displays information about obtained and created regular reports, information about worksheet container, and also information about regular report worksheets:

Key of regular report worksheet: 8

First resource identifier in new regular report: Worksheet_8

Number of new worksheet container elements: 4

First worksheet name: Table

First worksheet key: 8

Whether new worksheet is visible: visible

See also:

Example of pplib++ Library Use