Jump to content
Changes to the Jaspersoft community edition download ×

Java in iReport


2004 IR Help

Recommended Posts

By: bug123 - bug123

Java in iReport

2004-07-11 23:28

Hi, I am new in jasper. I have created a report and getting a value from database. [1/1/2003^2/2/2003^24/5/2004]

I want to use split the string into arrays and then print it out as

1/1/2003

2/2/2003

24/5/2004

How can I do this? Or is it possible??

Thanks.

 

 

 

 

By: Juan Ara - fi2net@Spain - laureke

RE: Java in iReport

2004-07-12 00:22

Maybe u can declare some reports variables (date1,date2,date3) and make them eval. in the apropiate group with the expresion: (or reset on report, u decide)

date1:

$F{yourDateField}.subString(0,8)

date2:

$F{yourDateField}.subString(8,16)

date3:

$F{yourDateField}.subString(16,24)

 

 

 

 

By: bug123 - bug123

RE: Java in iReport

2004-07-12 00:43

Are their any while or for loop function in iReport?

Thanks.

 

 

 

 

By: bug123 - bug123

RE: Java in iReport

2004-07-12 00:45

As date1, date2....is an unknown, I can't declare report variables. There maybe hundred date in one record field when retrieving the record.

Are there any suggestion?

 

 

 

 

By: Juan Ara - fi2net@Spain - laureke

RE: Java in iReport

2004-07-12 02:08

It's only an idea. Let's try to explain it:

Supossing you have a main group (mainGroup)

You create a group (dateToPrint).

 

Variable: dateToPrint

InitialExpresion: $F{aLotOfDates}

Reset: Group, mainGroup.

Expression: $V{dateToPrint}.subString(8)

(subString(int) --> beginIndex )

//maybe control string length:

//Expression new String(dateToPrint.length>8 ? $V{dateToPrint}.subString(8) : $V{dateToPrint})

 

Field: aLotOfDates

Your query field.

 

Variable: dateToPrintGroupCount

type=Integer

Reset=Group,mainGroup;

Initial=new Integer(0);

Calculation: Count;

 

Ok, now we can "iterate" through your variable, since each time it enters the group it will have a new value (since it's growing down) so, our dateToPrint group expression should be $V{dateToPrint) (Here is what I think can fail, I don't know if JR can have a variable as group expr. but I think yes).

 

Then, when printing your date, just print this expression:

$V{dateToPrin}.subString(0,8)

 

Do the traces and think about it, if you don't get it, drop me an email.

 

 

 

 

 

 

 

By: Juan Ara - fi2net@Spain - laureke

RE: Java in iReport

2004-07-12 02:10

Forgot to mention, depending how JR performs variable calcs, u can lost your first date, so you can have two print fields:

1: Print when expresion: CountGroup (I put the variable) = 0: print field: aLotOfDates.subString(0,8)

 

2: Print when expresion: CountGroup != 0 dateToPrint.subString(0,8)

 

 

 

 

By: Juan Ara - fi2net@Spain - laureke

RE: Java in iReport

2004-07-12 02:11

And think about nested reports or nested DataSources or even writing an scriptlet class, that makes work much more easy.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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