javajasper-reportsdynamic-jasper

DynamicJasper: How to avoid duplicate values in report's column?


I have created a sample report using the DynamicJasper library. In the report, I need to avoid to print repeated values in a column.

For example, The report has "Dept No" column. Which will be similar for some employees and its in asc order. Which mean it will be only as 1, 2, 3 etc. So, the dept no 1 will be used for some employees and 2 for some employees and so on.

So, here I need to avoid the dept no for an employee in second row, If the employee belongs to first row employee's department.

Sample Report

In the above image, the department no 1 is common for the employee no 101, 102, 103, 104 and 105. So, If dept no is avoid repeated values, then the employee no 102, 103, 104 and 105 would have empty in dept no column and which will be looking like as a group.

How to avoid the repeated values in a column with DynamicJasper?


Solution

  • Without seeing the code, it's difficult to know exactly what to recommend. The ColumnBuilder class has a setPrintRepeatedValues method that can be used similar to the following:

    ColumnBuilder.getInstance()
     .setColumnType(...)
     .setColumnProperty(...)
     .setTitle(...)
     .setWidth(...)
     .setPrintRepeatedValues(false)
     .build();
    

    The line of interest that should suppress repeated values is:

     .setPrintRepeatedValues(false)