Friday, 4 December 2015

Tip : Tab space issue with Field when its value having more characters

Hi,

Problem Statement : 
In some requirements, we need to print larger text value of a field in the reports & we do it dragging to the report console as usual but will stop with an error saying
java.lang.ArrayIndexOutOfBoundsException: 0 with out further error message. 

Solution : 
Its because  of the no compatability conversion understanding of SQL and Java to handle the spaces or tab spaces in the string value. 

We can overcome it at SQL level by using "replace" funciton. 

Lets say, the column name could be ProjectDescription in the SQL code. 
 & Lets assume one of the values for it is "This is a reporting project, this report is used to find the maximum of something and etc ..........up to some 3000 characters description". 

In SQL code use "replace" function to the field as shown below. 

Syntax : 
" replace([column_name], CHR(9))  " 
Example : 
replace(ProjectDescription,CHR(9))

 NOTE :
# This example is Oracle SQL specific, if you are working on other DBMS soft wares, find the similar replace function it and test. 

Similar issues can be found at below threads from community
1) http://community.jaspersoft.com/jasperreports-library/issues/4631
2) http://community.jaspersoft.com/questions/803333/tabs-text-mess-pdf-output
3) http://community.jaspersoft.com/questions/532690/using-tab-escape-sequence-text-field-expression

I hope this helps some one. !

Cheers..!
:-) :-) 
 

No comments:

Post a Comment