| 1 | # perl | ||
| 2 | # | ||
| 3 | # Minimal report example, data rows given as object reference | ||
| 4 | # | ||
| 5 | # PORF Perl Open Report Framework | ||
| 6 | # | ||
| 7 | # Ralf Peine, Wed May 14 10:39:48 2014 | ||
| 8 | # | ||
| 9 | #------------------------------------------------------------------------------ | ||
| 10 | |||
| 11 | use warnings; | ||
| 12 | use strict; | ||
| 13 | |||
| 14 | use Report::Porf::Framework; | ||
| 15 | |||
| 16 | sub run_example { | ||
| 17 | my $person_rows = shift; # Param1: Reference to list of objectes | ||
| 18 | my $format = shift; # Param2: Optional: format of report | ||
| 19 | |||
| 20 | $format = 'text' unless $format; | ||
| 21 | |||
| 22 | my $count_rows = scalar @{$person_rows}; | ||
| 23 | my $out_file_name = "result_minimal_object_${count_rows}.${format}"; | ||
| 24 | |||
| 25 | # --- create Report ------------------------------------------------------- | ||
| 26 | my $report_frame_work = Report::Porf::Framework::get(); | ||
| 27 | my $report = $report_frame_work->create_report($format); | ||
| 28 | |||
| 29 | # $report->set_verbose(3); # uncomment to see infos about configuring phase | ||
| 30 | |||
| 31 | # --- Configure Report ---------------------------------------------------- | ||
| 32 | |||
| 33 | $report->configure_column(-header => 'Prename', -value_object => 'get_prename()' ); # long | ||
| 34 | $report->conf_col (-h => 'Surname', -val_obj => 'get_surname()' ); # short | ||
| 35 | $report->cc (-h => 'Age', -vo => 'get_age()' ); # minimal | ||
| 36 | |||
| 37 | $report->configure_complete(); | ||
| 38 | |||
| 39 | # --- print out table ----------------------------------- | ||
| 40 | |||
| 41 | $report->write_all($person_rows, $out_file_name); | ||
| 42 | |||
| 43 | # --- return count of entries --------------------------- | ||
| 44 | |||
| 45 | return ($count_rows); | ||
| 46 | } | ||
| 47 | |||
| 48 | 1; |