0

In JasperReports report I am looking for "How can I increment a variable using report_count and start with I,II,III... or a,b,c" like this:

This is page 1
No Name Add
1  ---- ---
2  ---- ---
3  ---- ---
4  ---- ---
5  ---- ---

This is page 2
No Name Add
6  ---- ---
7  ---- ---
8  ---- ---
9  ---- ---
10 ---- ---

and I don't know how can I change all the number 1,2,3... to a,b,c or I,II,III...

1 - a    or 1 - I
2 - b       2 - II
3 - c       3 - III    
.....................

I'll appreciate any help.

Alex K
  • 22,315
  • 19
  • 108
  • 236
Mr.Phuong
  • 30
  • 5

1 Answers1

2

For a, b, c, etc. you can take the count variable i = 1, 2, 3 ... and add 96 so that i=97, 98, 99 ... which are the ascii codes for a, b, c,...

You find the ascii codes here and then you could put the following statement into a variable to convert to a,b,c,...:

java.lang.Character.toString ((char) $V{REPORT_COUNT}+96)

Change the evaluation time of the variable to "Report".

Regarding the roman numerals, Java does not have any classes in the standard library, so you have to add a jar-file with this class in it.

Community
  • 1
  • 1
johansson.lc
  • 322
  • 2
  • 12
  • thank you for your help, but i looking for jasper report design, Can you descript clear where i can put statement to convert them inside report design??? – Mr.Phuong Jul 12 '13 at 01:45
  • I changed the statement. I think you can pretty much paste that statement into the variable expression of a variable. – johansson.lc Jul 12 '13 at 11:25
  • it's very useful for my report, one again thank you Johansson.lc – Mr.Phuong Jul 13 '13 at 05:03
  • hi Johansson, i looking for code start with I, II, III, IV, V...but i don't see it in the ascii codes. Can you help me? – Mr.Phuong Jul 26 '13 at 04:02
  • It does not exist as ascii codes.You have to add a jar file for it, as I said above. – johansson.lc Jul 28 '13 at 16:15
  • You are very correct. Thanks. However for newbies like me. Create a variable, make it java.lang.Character and in variable expression give (char)($V{REPORT_COUNT}+96)) Which gives you a,b,c.. – Kannan_SJD Mar 05 '14 at 15:43