Jump to content
Changes to the Jaspersoft community edition download ×

Using tab escape sequence in text field expression


gdotzlaw

Recommended Posts

I have a Text field (java.lang.String), and want to have an expression like this:

$F{TYPE1} + "\t" + $F{PHONE1} + "\n" +
$F{TYPE2} + "\t" + $F{FIELD2}

to acheive output that looks like:

Phone        (847) 719-2290
Fax             (847) 719-2291

So, my proble is the new line escape sequence ("\n") works great, but the tab is ignored, so my output looks like this

Phone(847) 719-2280
Fax(847)719-2291

What am I doing wrong?

 

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

I think it's better to work with separate cell (column), one for the TYPE and another for the number, so you can control the pixel-range between them.

the escape sequence "\t" seems to be useless in a format lyke pdf, xls...

 

Link to comment
Share on other sites

Yes, I know how to place fields on the layout. My question was related to building an expression that can accomodate whether or not data is present, collapsing or expanding based on data being present. The latest version of iReports informed me that valid escape characters included the "\t", but since it does not work, it is either a bug, incorrect documentation, or I am simply not using it correctly.

Anyway, here is what I am trying to do. Suppose I place the following fields on my detail band.

COMMTYPE1                      COMM1
COMMTYPE2                      COMM2
COMMTYPE3                      COMM3

Assume now, if COMMTYPE2 and COMM2 are blank, COMMTYPE1, COMMTYPE3, COMM1 and COMM3 contain values. I do not want COMMTYPE2 or COMM2 to take up space in the detail band, so what should print is:

COMMTYPE1                      COMM1
COMMTYPE3                      COMM3

The question now becomes (since I can not build an expression that checks for blanks and uses "\t" to indent and "\n" to start on a new line) is there a way for fields placed on a layout (COMMTYPE3 and COMM3 in this example), to slide up, based on the object(s) above?

I don't see how to accomplish this in iReports, unless one has to create a subreport.

Link to comment
Share on other sites

 Ok, fine but how did you solve the "\t" Problem? Is there an HTML look-like Table? The crosstab isn't the solution because it has to be binded with the datasource and i want to specify my own expression.

Seeya

Code:
"Date\t\t" + $F{invoiceDate} + "\n" +"Echéance paiement\t\t" + $F{dueDate}
Link to comment
Share on other sites

I did not solve the "\t" problem; iReports/Jasper does not support it, so it must be a bug in the software (since it indicates that it is one of the supported escape sequences. I simply placed individual fields for 7 COMMTYPE and 7 COMM fields, and set them all to "remove line when blank" so that they disappear when not being used.

I did mess around with trying to get an HTML table to work without any success, so I think individual fields is the only solution to my problem.

I did not need to use subreports.

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