Using a Java Report Postprocessor
What is a Java Report Postprocessor
A Java Report Postprocessor is a java class that will run right after the Excel template was filled with data, and will allow manipulating the XLSX file using Apache POI XSSF API.
This allows basically every operation on the XLSX file (modify charts, add pictures, modify styles, and etc.).
You can retrieve all the data available to the report from the Java code, and add more data that will be available to the Java Report Streaming Class. You can also use the same database-related tools as in the Java Preprocessor Class.
When to Use Java Report Postprocessor
A Java Report Postprocessor should be used when complex operations are required on the XLSX file, and when including these operations as script in the template represent a maintenance challenge.
However, a Java Report Postprocessor is not necessary if you use Large Data Mode to just insert large amounts of data in the document, as the Report Postprocessor requires loading the whole document to memory for processing.
How to Use Java Report Postprocessor
Creating the Report Type
In the report type’s command steps, anywhere between the first
ksc_run_excel_report line and the last
ksc_end_report_parameters line, add the parameter
REPORT_POSTPROCESSOR_CLASS, with the value being the fully qualified class name of your Postprocessor class. For example, for the class
com.hpe.ppm.excelreports.SamplePostProcessorClass that you can find in the attached bundle in the folder
6 - Using a Java report post-processor, the line would be:
Creating the Java Report Postprocessor Class
You should create a Java class that extends the existing abstract class
com.mercury.itg.common.excel.exporter.data.ExcelReportWorkbookPostprocessor. The single method to implement is:
public void processWorkbook(XSSFWorkbook wb)
You can then directly work on the passed XSSF workbook object to modify the report XLSX document.
For more information, you can refer to the sample postprocessor class
SamplePostProcessorClass.java located in the attached bundle (in the path
6 - Using a Java report post-processor\1 - Sample Report PostProcessor source code\com\hpe\ppm\excelreports ).
Deploying the Java Report Postprocessor Class
Deploy the Java Report Postprocessor class in the same way as you deploy a Preprocessor class. See Deploying the Java Preprocessor Class.
Creating the Excel Template
There is nothing special to do on the excel template if you are using a Java Report Postprocessor. The only limitation is that you cannot fill the template using Large Data Mode.
Example of Report Using a Postprocessor
You can find an example of an Excel template and the resulting report in file
Samples\6 - Using a Java report post-processor. The source code and a jar version of the Java Postprocessor are included.