1

I have a table component which shows some records in a group of year like this

For example:

Year   Month    SumMonth //group header
2009   Jan      1000     //table details
       Feb      2000
       Mar      3000
2009   xxxx     6000     //group year footer
2010   Jan      1100     //table details
       Feb      1200
2010   xxxx     2300     //group year footer

The "xxxx" part in the above table is which i need to modify.

I want to display the format like this:

"Jan-Mar" (for 2010 is "Jan-Feb")

The question is how to get the value of first month and last month and concatenate them into a variable (or not need to?), so that I can put it into footer?

The other problem is that how can I hide the records in specific year?

For example the final modified display may like this:

Year   Month     SumMonth //group header
2009   Jan-Mar   6000     //group year footer
2010   Jan       1100     //table details
       Feb       1200
2010   Jan-Feb   2300     //group year footer

You can see the whole records in 2009 are hided in the above table. Which options or what expression should I set?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user1264222
  • 225
  • 2
  • 4
  • 12

1 Answers1

5

Create a variable called FirstMonth. Its Expression is $F{month} and its Calculation is First. Create a variable called LastMonth. Its Expression is $F{month} and its Calculation is None. In your case both should reset for each year. Then in the year footer it is as simple as this:

$V{FirstMonth} + "-" + $V{LastMonth}

If you don't want to see details for Year 2009 then set a Print When Expression in the detail band like ${Year}.intValue() != 2009

mdahlman
  • 9,204
  • 4
  • 44
  • 72
  • thanks your reply. I have successful to do the concatenate part. – user1264222 Mar 19 '12 at 14:41
  • But I still stuck on the Print When Expression part....As I said, it was the table component but not the report detail band...so I cannot found any "Print When Expression" in the table component detail band. The only I found was "column print when", but it is not useful for my case, It will disappear a whole column... – user1264222 Mar 19 '12 at 14:44
  • I tried to place the code "<![CDATA[$F{YEARS}.intValue() != 2009]]>" inside the detail part of the table component, but it fails...could you give some ideas? Thanks a lot again!! – user1264222 Mar 19 '12 at 14:46
  • When you click on the detail band in the 'Report Inspector' the properties menu should for it should show a "Print When Expression" property. That is where you will paste: ${Year}.intValue() != 2009 – precose Mar 19 '12 at 15:26
  • Sorry, I didn't notice the use of the Table component. I'll try to update my answer later. You should perhaps split the 2 questions into 2 different questions, since they are not closely related (except that you need both in your report). – mdahlman Mar 19 '12 at 16:06
  • OK... I am waiting for your question. Since hiding rows in a table component is not related to creating those variables. Please open a new question. I don't know the answer immediately, but it's a good question. – mdahlman Mar 20 '12 at 17:18
  • I'm glad to hear that. About the "hiding rows" part, now is skipped since its not so urgent and critical problem but it is a good challenge for us to discover a way to solve this after a while. – user1264222 Mar 21 '12 at 04:01
  • I have posted a new related question about the ireport, and I am pleased to invite you to look around the problem by this link:[link](http://stackoverflow.com/questions/9798399/how-to-group-serval-same-value-field-into-a-single-cell-in-ireport) , please feel free to look around it~~THANKS a lot!!! – user1264222 Mar 21 '12 at 04:06