Jump to content
Changes to the Jaspersoft community edition download ×

horizontally/vertically stretch cell in crosstab.


huynhkchau

Recommended Posts

I'm new at iReport. In my project, i need to design two reports as follows. I use crosstab to present both but I have some problem with it. Please help me out. The deadline is coming :((

 

Jan

Feb

Produce

Sell

Produce

Sell

Product A

10

5

12

6

Product B

5

2

2

5

With this report, I can not horizontally stretch header cell Jan/Feb to fix with Produce+Sell like the figure.i.e. Produce=Sell=50 and Jan=100, but with crosstab I can only set  maximun of Jan is 50.

 

Product A

Product B

Jan

Produce

10

5

Sell

5

2

Feb

Produce

12

2

Sell

6

5

With this report, I can vertically stretch header cell Jan/Feb.The alignment of crosstab when I preview in iReport is okb ut it is not proper in web. The Jan cell is stretched but it's height is not fix with the total height of Produce and Sell.

Note: I checked "Stretch with overflow" with stretch type is "Relative to band height'.

Thanks in advance.

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Yes, this is doable. What you probably need is a "union" in your query. For example

Notice how I have added a new field called "Type". Now simply add a row group on "Product" and Column groups on "Date" and "Type" and for the calculation add a "Sum" for the "Count_" field.

That should do the trick.

Hope this helps!

kchaudhry

 

Code:
select 'A' as 'Product', '04/08/2009' as 'Date', 10 as 'Count', 'Produce' as 'Type'unionselect 'A' as 'Product', '04/08/2009' as 'Date', 5 as 'Count', 'Sold' as 'Type'

Post Edited by kchaudhry at 04/21/2009 15:07
Link to comment
Share on other sites

First of all, please don't edit your original post to ask a different question. This can be misleading to other users since the response provided will not relate to the question.

Now coming to your question, you can highlight your date element and click on "Enlarge between margins". If this doesn't solve your problem then post your jrxml here.

Link to comment
Share on other sites

Sorry kchaudhry,

but seem it doesn't work to my report. With ireport 3.0.0 I tried "Enlarge between margins", the element width changed to 100 but I got error when compiling the code "Element reaches outside Date header width..."

With ireport 3.5.0 I tried "Adapt to parent" but it didn't work too...

Enlosed is the jrxml file.

Thanks

Code:



Post Edited by huynhkchau at 04/22/2009 03:41



Post Edited by huynhkchau at 04/22/2009 03:42
Link to comment
Share on other sites

I tried your jrxml and got the same error using ireports 3.0 Then I created another report using your query and it worked fine. I'm not sure why that is happening. I have attached my jrxml.

One thing that I noticed was that you had column and row totals shown on the report while your calculation was set to "Nothing". So I removed those rows and columns as they aren't going to do anything.

Code:
<?xml version="1.0" encoding="UTF-8"  ?>						select 'A' as "Product", '04/08/2009' as "Date", 10 as "Count", 'Produce' as "Type" from dualunionselect 'A' as "Product", '04/08/2009' as "Date", 5 as "Count", 'Sold' as "Type" from dual																																																																																																																																																														$F{Product}																																																																																		$V{Product}																																							$F{Date}																																																																																		$V{Date}																																							$F{Type}																																																																																		$V{Type}																																$F{Count}																																																																																$V{Count_Nothing}																																																																																																																																																																																											
Link to comment
Share on other sites

Hi kchaudhry,

Thanks so much for your support. After reading your file, I solved the problem.:)

As I see, the Date header element  is not horizontally stretch only vertically stretch. So instead of bordering the  element  properties, I border the cell properties and set the Date header width to fix with its output result. The report will look like the above picture. 

But anyway, I still hope  that header element  can auto horizontally stretch :p.

Again,

Thanks

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