Jump to content
We've recently updated our Privacy Statement, available here ×

using a parameter to construct a field


tom_45

Recommended Posts

Hi,

 

I have an excel file that contains a few columns with article descriptions like short_title_NL,short_title_EN, short_title_DE

I want to generate a report in the language that a user has chosen via a prompted parameter.

e.g. the user types in NL for the variable Language, and the chosen column to display in the report would be the description in dutch, so the field short_title_NL would have to be printed.

I've tried to create a text field like this:

$F{"short_title_" + P{Language}}  in the hope that it would evaluate to $F{short_title_NL}

But I get the error 'Field not found: "short_title_" + P{Language  --- net.sf.jasperreports.engine.design.JRDesignExpression

 

Can someone point me in the right direction? Please bear in mind  that this is an excel file.

Thanks,

Tom

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic


Hi, 

Thanks I don't know if this would work with excel (can't use sql).

But I got the same result using this in the expression editor:

 

( $P{taal}.equals("NL") ? $F{short_title-nl_BE} + " " + ($F{baseline-nl_BE}!=null?$F{baseline-nl_BE}:"") :
( $P{taal}.equals("FR") ? $F{short_title-fr_FR} + " " + ($F{baseline-fr_FR}!=null?$F{baseline-fr_FR}:"") :
( $P{taal}.equals("DE") ? $F{short_title-de_DE} + " " + ($F{baseline-de_DE}!=null?$F{baseline-de_DE}:"") 
    : $F{short_title-en_US} + " " + ($F{baseline-en_US}!=null?$F{baseline-en_US}:"")
)))

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...