Jump to content

Jaspersoft Studio: How to break new line when checked by some characters e.g. "/","@" ?


eggchun32
Go to solution Solved by jabrown,

Recommended Posts

My Jaspersoft Studio version: 6.5.1.final

As my question mentioned, I want to break new line for my data when it detect some characters such as "/".

For example,
$F{data} = "AB/CD/E/F/"
The layout that I want to export in PDF:
-->"AB/CD/
       E/F/"
-->"AB/CD/
       E/
       F/"
-->"AB/
       CD/
       E/
       F/"

I have also researched on Google and found that some solutions are using split method in textfield: $F{data}.split("/").

I have tried but it seems not work for me when export in PDF just like the picture below.
splitmethod.png.f45f44d4c3afe815d562711e494652e0.png

Is that any possible solution to solve this layout problem?

Or am I using the split method incorrectly?

Thank you!!

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

  • Solution

Hello,

You should be able achieve this by using the following expression for your text field.  I belive the Java function you'll want to use is replace rather than split.  You will replace your defined character with a new line.

"AB/CD/E/F/".replace("/","rn")

Your JRXML for the text field value will be as follows.

<textFieldExpression><![CDATA["AB/CD/E/F/".replace("/","rn")]]></textFieldExpression>

I hope this helps solve your challenege!

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...