Monday, March 7, 2016

Jasper Report: How to draw vertical or horizontal line



Horizontal line
Drag line into design band. In this example, we are using Summary Band.
Change line height size to 1px
Vertical Line
Change line width size to 1px





Jasper Report: How to expand crosstab column header title



Below is the report output that we would like to achieve.











Goto Report XML source and add headerPosition = “Stretch” in the related columnGroup tag.
Below is the example:

<columnGroup name="TajukColumn1" height="20" totalPosition="End" headerPosition="Stretch">






















That’s all.

Jasper Report: How to change pattern expression conditionally



Below is the example of expression that can be used to change pattern expression conditionally.

IF(EXACT($P{myNumber},"Dollar"),
new java.text.DecimalFormat("#,##0.00").format($F{totalCost}),
         $F{totalCost}
)

* The above expression must be typed in Text Field Expression

Sunday, March 6, 2016

Jasper Report: How to divide BigDecimal number



The following example shows how to divide a BigDecimal format field.






















JumAset is a Jasper Report field with java.math.BigDecimal data type. Below is its screen shot:













Drag JumAset field into Detail Band. Below is the example:










Click at JumAset field under column header TOTAL OF ASSET IN MILLION, then go to Text Field expression and type the following expression:

$F{JumAset}.divide(new BigDecimal("1000000"))

Below is the screen shot:

Finally, compile and run the report and below is the example of output:















That’s all.

Saturday, March 5, 2016

Contact Us



Feel free to drop your feedback about this website.

Jasper Report: How to pass parameters to crosstab



In order to pass parameters into crosstab, first of all, we need to create parameters related in main report. Below is the example:




























After that, we need to create another 2 parameters in crosstab (crosstab parameters). Below is the example:

























                          Please ensure that all of the parameters in the main report and in crosstab section are using the same name and class. Below is the example:













Nevertheless, if you are using Jaspersoft Studio Community version, most of the time your IDE will have problem creating crosstab parameters. Therefore, alternatively you can create crosstab parameters in XML source and then assign crosstab parameters value with main report parameters value using <parameterValueExpression> tag. Below is the example:











                                           
Finally, compile and then run your report.

That’s all.

Home



Welcome to simplycodes.blogspot.my
Nothing much to say, hopefully this little effort will benefit whoever is in need.

Thanks.
nasarudin.abdullah@gmail.com
Seremban, Malaysia

Jasper Report How To


  1. How to avoid merged cell in excel
  2. How to bold a word in a single Static Text
  3. How to change data adapter connection
  4. How to change patern expression
  5. How to divide BigDecimal number
  6. How to draw vertical or horizontal line
  7. How to expand crosstab column header
  8. How to format numeric data in Excel
  9. How to pass parameters to crosstab
  10. How to remove extra row when exporting to Excel