Six Stars

Project scenarios

a.PNG

 

Scenario 1 :

I have to insert comma in the values.

ex: 32825 o/p : 32,825

3281564 o/p : 3,281,564 

Before third digit i have to place comma.

 

Scenario 2 :

I have to replace the values -7.8 to (7.8)

need to replace open and close brackets for minus values.

1 ACCEPTED SOLUTION

Accepted Solutions
Six Stars

Re: Project scenarios

It worked after changing into this.

 

row11.EBITDA_MARGIN_Dec_17 .contains("-")?"("+row11.EBITDA_MARGIN_Dec_17 .replace("-","")+")": row11.EBITDA_MARGIN_Dec_17; 

13 REPLIES
Twelve Stars

Re: Project scenarios

@Darmesh,

1:- if you were using tFileOutputExcel using to populate data,for the number filed you can specify Thousands separator.

 

Untitled.png

2:- you can use the below one.

!row1.filed.equals("") || row1.filed!=null||row1.filed.contains("-")>0?"("+row1.filed.replace("-","")+")": row1.filed

Manohar B
Six Stars

Re: Project scenarios

@manodwhb

for scenario2 . am getting below error

 

a.PNGb.PNG

Six Stars

Re: Project scenarios

It worked after changing into this.

 

row11.EBITDA_MARGIN_Dec_17 .contains("-")?"("+row11.EBITDA_MARGIN_Dec_17 .replace("-","")+")": row11.EBITDA_MARGIN_Dec_17; 

Twelve Stars

Re: Project scenarios

try this

!row1.filed.equals("") || row1.filed!=null||row1.filed.contains("-")?"("+row1.filed.replace("-","")+")": row1.filed

Manohar B
Six Stars

Re: Project scenarios

@manodwhb

It is working fine. But sometimes column will contain null values. so how to overcome null pointer exception.

Six Stars

Re: Project scenarios

@manodwhb @TRF @rhall_2_0

 

It is working fine. But sometimes column will contain null values. so how to overcome null pointer exception.

Twelve Stars

Re: Project scenarios

Try the below one.

!row1.filed.equals("") || row1.filed!=null||row1.filed.contains("-")?"(row1.field==null?row1.fieldSmiley Sad"+row1.filed.replace("-","")+")"): row1.filed
Manohar B
Six Stars

Re: Project scenarios

Error after using the below code

 

String literal is not properly closed by a double-quote

 

!row1.filed.equals("") || row1.filed!=null||row1.filed.contains("-")?"(row1.field==null?row1.field"+row1.filed.replace("-","")+")"): row1.filed

Twelve Stars

Re: Project scenarios

try the below one.

 

!row1.filed.equals("") || row1.filed!=null||row1.filed.contains("-")?(row1.field==null?row1.field:"("+row1.filed.replace("-","")+")"): row1.filed

Manohar B
Six Stars

Re: Project scenarios

it has null values.

 

error :

 java.lang.NullPointerException

Twelve Stars

Re: Project scenarios

this should fix for the null pointer exception row1.filed

 

if you still gets you have look for other columns may be causing null pointer exception.

 

 

!row1.filed.equals("") || row1.filed!=null||row1.filed.contains("-")?"("+row1.filed.replace("-","")+")": row1.filed

Manohar B
Six Stars

Re: Project scenarios

still the same error.

But i want to load the null values into the excel without getting null exception error.

a.PNG

OR

Is there any other method to convert negative values to () brackets.

Twelve Stars

Re: Project scenarios

@Darmesh, i am able to get with below expresion. please check

 

(!row3.newColumn1.equals("") || row3.newColumn1!=null) &&row3.newColumn1.contains("-")?"("+row3.newColumn1.replace("-","")+")": row3.newColumn1 

 

Manohar B