JasperReports Oddities #2: Indenting in Crosstabs

The expectation that using the Left Indent or Right Indent facility for your JasperReports Text Field or Static Text to ensure that it is spaced “just so” is perfectly reasonable. Let’s test that theory – just drop in your text field, position it carefully, right align your text and indent by 5 pixels. It looks great in the Studio designer, just what you intended with your indent. And then you press “Preview”, your draft report is generated and … well, it’s no longer indented…

What just happened? You indented it correctly, right? It looks indented in the Studio designer window, also right? Sure, but it just doesn’t work like that.

There’s a simple, albeit unintuitive fix, for this: firstly, remove the indent value you’ve set, either by deleting the code or adjusting it in the GUI. Secondly adjust the border padding, either in the code, else from the Borders tab or even from within Advanced settings >Graphic>Line Box>Right Padding (or Left Padding if that’s what you’re looking for), by adding your 5 pixel adjustment there instead.

Okay. Now it looks fine in the designer and it looks fine in Preview.

So it’s now fixed, but why? Does it make actually sense? Well, yes. It may not be intuitive but it is correct. Simply put, the cell properties of the crosstab take priority over the text properties of the field.

On a side note this also applies to crosstabs in other graphical interfaces e.g. Crystal Reports. Don’t question it , just accept it and give yourself time to worry about more important things in your life.