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

How to Center Crosstab Table?


gorfimus

Recommended Posts

I ave a crosstab table in one of my jasper reports and I want to center it horizontally.  The number of columns in my crosstab table is of course dynamic, so I need a way to center it regardless of the number of columns.

Is this possible?  And if so, how?

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

 Have you tried to place the crosstab in frame that is centeral in the main report, so the crosstab is subreport. Try to place the crosstab element in the left-top of this subreport, so at the minimum data it will be in the center of the report.

Link to comment
Share on other sites

Thanks for the suggestion.  I'm not sure it would work.  I already have the crosstab as a subreport and I'm not sure placing the subreport in a frame would make a difference.  I don't see any special positioning properties of a frame element that couldn't already be used by a subreport element.  I could be mistaken though?

I ended up solving this by creating multiple subreports.  For my situation, the number of columns in my crosstab can only vary between 3 and 8 columns, so I have 6 different subreports.  Given the number of columns, I know the actual width of the crosstab when it has 3 columns, 4 columns, etc, so each subreport starts the crosstab at the appropriate x coordinate for its number of columns.  The main report then selects the correct subreport to render, depending on the number of columns in the crosstab.

Link to comment
Share on other sites

I used concatenation in the subreportExpression.  The query of the main report determines the number of columns and stores it in a field.  I then use that field in the subreportExpression.

Example:

<subreport>
    ...
    <subreportExpression><![CDATA["subreportName" + $F{columns} + ".jrxml"]]></subreportExpression>
</subreport>

Link to comment
Share on other sites

  • 1 month later...

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