2

We wants to use case statament like word case setting in jasper report. We have some sentences in our DB is uppercase and we want to change first character is upper and the other one is lowercase. How can we do it in jasper reports?

Thank you.

2 Answers2

2

On the Jasper report designer;

  1. Right click on the TextField for the sentence
  2. Click show properties
  3. Next to the expression field open the expression editor
  4. Input the below statement on the expression editor

$F{some_field}.substring(0,1).toUpperCase()+$F{some_field}.substring(1,$F{some_field}.length()).toLowerCase()

For instance: the username's first letter is converted to uppercaps on the below expression. For your case it will be sentence

For instance the username's first letter is converted to caps on the below expression

  1. Press Finish Button to save, then run the report
Duncan O. N.
  • 778
  • 12
  • 24
1

When you design the report you put references to database fields somewhere on the page. When you open that for editing (right-click -> edit expression in iReport) what you really write is Java code returning a String, and reference like $F{SOMETHING} is a String type variable. Nothing prevents you from putting in some logic, like:

$F{SOMETHING}.startsWith("A") ? "cool" : "not cool"
Deltharis
  • 2,320
  • 1
  • 18
  • 29