Multiple reports from a single report definition

Home » Report development » Multiple reports from a single report definition
Report development No Comments

It is often the case that there might be two (or more) versions of a report in O-Calc Pro. For example a summary version and a detailed version, or a text only version and a version that includes images or charts (see http://o-calcpro.com/wiki/2015/12/03/adding-a-custom-chart-to-a-report/ ). Rather than implementing such reports in multiple report definitions you can simply set a singe definition to do it as follows:

Override the property “SubtypesCount” and return the number of ADDITIONAL reports that will be implemented. The report always implements one report so if you wish to implement a total of 4 (for example) you would have this property return 3.

  1. //implement more than one additional report subtype (total will be this number plus the master)
  2.         public override int SubtypesCount { get { return 3; } }

Next we must indicate the name that each report will have by updating the “Name” property (and also the “Description” assuming it does not simply reflect the value of “Name”).

Here we see the value “Subtype” used where O-Calc Pro indicates which report it is asking to be processed.

  1. public override String Name
  2.         {
  3.             get
  4.             {
  5.                 switch (SubtypeIndex)
  6.                 {
  7.                     default:
  8.                     case 0:
  9.                         return "Analysis Summary";
  10.                     case 1:
  11.                         return "Analysis Report";
  12.                     case 2:
  13.                         return "GO95 Analysis Summary";
  14.                     case 3:
  15.                         return "GO95 Analysis Report";
  16.                 }
  17.             }
  18.         }

It is important that each of these values be unique so that the user will know which report is which and will be able to filter them individually.

Finally the implementations of “public override void CreateReport(PPLMain pPPLMain, List pSelectedFiles)” (frequently no change is needed here) and “public override void AddPole(PPLPole pPole, String pPoleName)” need to have similar tests for “Subtype” and conditional logic to produce the correct report added as appropriate.

In this way reports that share portions of their implementation can be contained in a single report definition for ease of implementation and maintenance.

  1. public override void AddPole(PPLPole pPole, String pPoleName)
  2.         {
  3.             switch (SubtypeIndex)
  4.             {
  5.                 default:
  6.                 case 0:
  7.                     BuildSummaryReport(false);
  8.                 case 1:
  9.                     BuildDetailedReport(false);
  10.                 case 2:
  11.                     BuildSummaryReport(true);
  12.                 case 3:
  13.                     BuildDetailedReport(true);
  14.             }
  15.         }

Facebooktwitterlinkedinmail