Istnieje kilka podstawowych procedór oraz jedna niezbędna zmienna w użyciu silnika raportów:
startReport() - uruchamia silnik raportów i rozpoczyna raportowanie
stopReport() - zatrzymuje silnik raportów i kończy raportowanie
__report__ - zmienna, gdzie raport jest przechowywany
report(reportName) - procedura tworzy raport w pakiecie typu office
Przykład 13.1. Table split procedure report example:
# start reporting - turn on reporting process startReport() table 'sport_cars': name weight speed cost 'skoda' 1200 260 10.000 'renault' 1360 280 10.500 'opel' 900 240 8.200 'VW' 1400 280 12.00 'Fiat' 1450 260 7.800 'Alfa Romeo' 1300 280 11.000 # This yields two tables - "sport_cars_part_1" and "sport_cars_part_2" tableSplit('sport_cars', split=[1, 2], seed=124, output=['sport_cars_part']) # stop reporting - turn off reporting process stopReport() # save report in repository save('tableSplitReport',__report__) # load report model from repository model = load('tableSplitReport') # print report to std.output print model.getAll().get(0).getReportAsString()
Output:
SplitTable: Input table: sport_cars (6 rows) Output tables: sport_cars_part_1 (1 rows) sport_cars_part_2 (5 rows)
Głównym celem użytkowania silnika raportów jest wygenerowanie raportu w pakiecie typu Office. Poniższy skrypt jest prostym przykładem, który pokazuje jak utworzyć raport w pakiecie typu Office.
Przykład 13.2. Table split procedure report example:
# start reporting - turn on reporting process startReport() table 'sport_cars': name weight speed cost 'skoda' 1200 260 10.000 'renault' 1360 280 10.500 'opel' 900 240 8.200 'VW' 1400 280 12.00 'Fiat' 1450 260 7.800 'Alfa Romeo' 1300 280 11.000 # This yields two tables - "sport_cars_part_1" and "sport_cars_part_2" tableSplit('sport_cars', split=[1, 2], seed=124, output=['sport_cars_part']) # do a trivial operation related to trans trans None <- 'sport_cars_part_1','sport_cars_part_2': pass # stop reporting - turn off reporting process stopReport() # this instruction will run office suite report()
Raport wygenerowany przez powyższy skrypt