Disabling Columns from JasperReport Dynamically
We can disable columns dynamically from Jasper Report based on our requirement.
Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.
I will give a simple example:
Suppose we are generating a report for a company’s contribution and loan amounts
and we want to disable columns with zero amounts.
- Select the column that you want to disable
- Go to that cell in the properties window
- Type the following in the expression window:
$F{loanrepay3}.compareTo(new BigDecimal(0)) == 1 ? Boolean.TRUE : Boolean.FALSE
The java.math.BigDecimal.compareTo(BigDecimal val) compares the BigDecimal Object with the specified BigDecimal value.
We are comparing the loan repayment amount to zero if it is greater than zero then we will get that column otherwise we wont.If we want both the values to be equal then compareTo will return 0 and it will return -1 when big decimal value is greater.
This function can be very useful for different type of comparison based on the requirement.
Thanks
Best Open Source Business Intelligence Software Helical Insight is Here